quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

No quicktype namespace.

Open mchlkoval opened this issue 8 years ago • 3 comments

I am a bit confused as to how to use this tool from anything outside of the CLI. Their example JSON result states that we need to simple include the NewtonSoft.JSON package and then proceed with stating using Quicktype.

Now, is the using QuickType only available after we produce the file? Or is there something else I am missing as calling in their example Artist.FromJSON is, I assume, impossible unless you already have the artist class ready to go before creating it?

In essence, i am wondering if someone has actual documentation of how to use this in the wild rather than just the CLI command.

mchlkoval avatar Dec 07 '17 14:12 mchlkoval

quicktype produces a file in the right panel for the JSON that's in the left panel:

screen shot 2017-12-07 at 7 05 33 am

You have to add that file to your project, add the JSON.NET package, and you're ready to go. Here's an example .NET Core project:

Artists.zip

Does this work for you?

schani avatar Dec 07 '17 15:12 schani

It does, so i guess in essence there is no real way to have it produce the file dynamically within the code itself, right? It is more of an offline (as in, generate file first, copy over, then use it) type of approach?

mchlkoval avatar Dec 07 '17 15:12 mchlkoval

You could use reflection to generate those types at runtime, but then you would have to use reflection to use them, and you'd lose all the advantages:

  • No support from the IDE when working with the data, like intellisense.

  • You would have to check that the types correspond to the schema you're expecting, i.e. in practice it would be dynamic typing.

schani avatar Dec 07 '17 20:12 schani