FSharp.Json is F# JSON serialization library based on Reflection it's written in F# for F#.
Find basic usage example to get an idea how to use the library.
Why we need yet another F# JSON serialization library? Well, if you happy with the library that you are using currently then probably you do not need another one. There are several available options to choose from:
- JSON Type Provider
- Json.Net aka Newtonsoft.Json
- Let me know what library I missed here
While all of these libraries do provide some good functionality all of them seem to have a weakness. Some of them are written in C# without out of the box support for F# types. Additionally null safety is alien concept in C# however it is a must in F#. Other libraries provide only low-level functionality leaving a lot of cumbersome coding work to library user. The type provider library forces developer to define JSON schema in form of json examples which is far from convenient way of defining schemas.
FSharp.Json was developed with these values in mind:
- Easy to use API
- Automatic mapping of F# types into JSON
- Out of the box support for F# types
- Null safety
FSharp.Json is pure F# library. It uses Reflection to get information about F# types at runtime. The code from FSharp.Data library is used for parsing JSON. The JsonValue type is internalized in the FSharp.Json library. The core of FSharp.Json library is located in single Core.fs file.
Following pages are describing main features and aspects of FSharp.Json:
- Basic Usage Example
- API Overview
- Supported Types
- Fields Naming
- Null Safety
- Type Transform
- Untyped Data
Each feature of FSharp.Json is thoroughly covered by unit tests.
API Reference contains automatically generated documentation for all types, modules and functions in the library.
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation.
The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.