Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write API for JsonProvider #32

Closed
ovatsus opened this issue Jan 25, 2013 · 12 comments
Closed

Write API for JsonProvider #32

ovatsus opened this issue Jan 25, 2013 · 12 comments
Assignees

Comments

@ovatsus
Copy link

ovatsus commented Jan 25, 2013

Allow to construct and/or modify typed JSON objects

Before reading the rest, see fsprojects/FSharpx.Extras#196 for the start of this thread

@rojepp
Copy link

rojepp commented Mar 27, 2013

+1. Preferably in a streaming fashion to avoid memory use.

@davidgrenier
Copy link

I prefer a declarative approach akin to XLinq and the markup combinators present in WebSharper.

If the type provider could generate camel or Pascal case functions that reflect the schema.

InvoiceDetailRequest [
    InvoiceDetailRequestHeader [
        invoiceId "X2235"
        InvoiceDetailHeaderIndicator [
            ...
        ]
    ]
    InvoiceDetailOrder [
        InvoiceDetailOrderInfo [
            ...
        ]
    ]
    InvoiceDetailOrder [
        InvoiceDetailOrderInfo [
            ...
        ]
    ]
    InvoiceDetailOrder [
        InvoiceDetailOrderInfo [
            ...
        ]
    ]
    InvoiceDetailSummary []    
] |> string

My personal use case is for cXML which uses DTD, even though it's dated I'm undecided at the time if it would be better to invest time on adding DTD support or just trust the schema inference which seemed to work well with sample cXML files.

@panesofglass
Copy link
Contributor

Retrieve default vega specs that could be modified and sent through VegaHub for rendering in a browser. @mathias-brandewinder and I were discussing the merits of trying to use the JsonProvider or writing and maintaining a library of DUs and records to match the vega grammar and spec samples.

@ovatsus
Copy link
Author

ovatsus commented Aug 9, 2013

On fsprojects/FSharpx.Extras#196 there's a couple of alternative for an immutable write API. It would be great if you could make an example with the kind code you want to write.

@ovatsus
Copy link
Author

ovatsus commented Oct 7, 2013

Here is another use case for it:
http://luketopia.net/2013/10/06/xml-transformations-with-fsharp/

@forki
Copy link
Member

forki commented Nov 1, 2013

Anybody planning to implement this?

@ovatsus
Copy link
Author

ovatsus commented Nov 1, 2013

I was planning on doing the simple scenario (just adding constructors) soon. Is that enough for you?

@forki
Copy link
Member

forki commented Nov 1, 2013

My use case is:

I have a sample like:

{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "assignee":{
        "id":1
    }
}

I want to overwrite the properties and post it to an url.

@ovatsus
Copy link
Author

ovatsus commented Nov 1, 2013

Would this work for you?:

type JsonT = JsonProvider<"Sample.json", RootName="Operation">
new JsonT.DomainTypes.Operation(2, "someBranch", "someOtherBranch", new JsonT.DomainTypes.Asignee(3))

Or do you get that sample from somewhere at runtime and then need to override one of the properties and then send back?

@forki
Copy link
Member

forki commented Nov 1, 2013

No, this would work.

At the moment I'm doing:

image

forki added a commit to forki/FSharp.Data that referenced this issue Nov 1, 2013
forki added a commit to forki/FSharp.Data that referenced this issue Nov 1, 2013
forki added a commit to forki/FSharp.Data that referenced this issue Nov 1, 2013
forki added a commit to forki/FSharp.Data that referenced this issue Nov 1, 2013
forki added a commit to forki/FSharp.Data that referenced this issue Nov 12, 2013
@ghost ghost assigned ovatsus Nov 22, 2013
forki added a commit to forki/FSharp.Data that referenced this issue Jan 22, 2014
@ovatsus
Copy link
Author

ovatsus commented Mar 7, 2014

@ovatsus
Copy link
Author

ovatsus commented Mar 16, 2014

Moving discussion to #529

@ovatsus ovatsus closed this as completed Mar 16, 2014
colinbull added a commit to colinbull/FSharp.Data that referenced this issue Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants