No quicktype namespace.
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.
quicktype produces a file in the right panel for the JSON that's in the left panel:
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:
Does this work for you?
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?
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.