Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:06:06+00:00 2026-05-30T20:06:06+00:00

I am trying to add a basic JSON type provider to fsharpx . At

  • 0

I am trying to add a basic JSON type provider to fsharpx.
At the moment I am struggeling with JSON Arrays. Consider the following test case:

type SimpleArray = JSON< "{\"items\":[{\"id\":\"Open\"},{\"id\":\"Pause\"}]}">

let a = SimpleArray()

[<Test>] 
let ``Can parse simple arrays``() = 
    a.items.[0].id
    |> should equal "Open"

    a.items.[1].id
    |> should equal "Pause"

The idea is that I want to use the first element in the array to get the type of the collection elements. Then I want to add a property “items” to the SimpleArray type that gives a list of this new type.

The code can be found in the github repo Github. The interesting part starts at line 38. As you can see the whole thing has to be recursive since the JArray could also contain nested JArrays.

| JArray list ->
    let newType = annotateAsJson list.[0] (runtimeType<obj> (ownerTy.Name + "_" + e.Key))
    ownerTy.AddMember newType
    Some(provideProperty
            e.Key
            newType // TODO: make this a list
            (fun args -> Expr.Coerce(<@@ (%%args.[0] : obj) @@>, newType)) // TODO: return the list
            :> MemberInfo)

Thanks,
Steffen

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:06:07+00:00Added an answer on May 30, 2026 at 8:06 pm

    What’s the question, exactly? It looks like you need to provide multiple types (e.g. in your example you’ve got the outer type containing items and then an inner type containing id). You probably want the inner type to be a nested type within the outer type. Then you make the provided items property contain a list of the inner type. Is there a particular aspect of that which you are having trouble with?

    EDIT

    If it’s just that you are wondering how to create the Type instance itself, have you tried

    typedefof<_ list>.MakeGenericType(newType)
    

    This presumes that the underlying value it itself an obj list, which is necessary since newType erases to obj.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add basic authorization to my request header. The code below compiles
I'm getting the following error from g++ while trying to add iterator support for
i have a pretty basic jquery question. im trying to add jscrollpane to my
Just being very basic here. I'm trying to post an activeResource as Json and
I'm trying to add some basic file-download functionality to my Rails application and have
I'm trying to add some basic rake tasks to the orientdb gem that will
I am trying to add some basic dynamic functionality to a web page. How
I am trying to add a basic dropdown list to my view with a
I have a very basic entity model which I'm trying to add custom validation
I am trying to add a property to a type using TypeDescriptor.CreateProperty in order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.