3 ms·
I can't speak for F#, but in Haskell we typically use the Aeson library for working with JSON data. You define a custom type to represent your JSON data and the
by solomonb 5y ago
I can't speak for F#, but in Haskell we typically use the Aeson library for working with JSON data. You define a custom type to represent your JSON data and then you write a parser to go from JSON data serialized as `ByteStrings` into your custom type. The parser is implemented in a Typeclass and you get to leverage adhoc polymorphism to map your serialized JSON into whatever type (or complex set of nested types) you need in a given context.
Now to your specific question, Aeson comes with a type called `Value` which represents JSON data directly. You can see the definition of `Value` [here](https://hackage.haskell.org/package/aeson-1.5.6.0/docs/src/Data.Aeson.Types.Internal.html#Value https://hackage.haskell.org/package/aeson-1.5.6.0/docs/src/D...).
`Value` is not particularly ergonomic but what you can do is parse the serialized JSON into `Value`, inject your additional JSON values into the `Object` HashMap, and then finally parse the `Value` term into whatever custom type you created for your application.