fsprojects / FSharp.Json

F# JSON Reflection based serialization library
Apache License 2.0
222 stars 26 forks source link

Q: how can I handle the reserved F# keyword 'type' in json string { "type": "abc", "weight": "123" } #50

Closed sanikolov closed 3 years ago

sanikolov commented 3 years ago

When I attempt to create a record for the above json string the F# compiler rejects it with FS0010 Incomplete structured construct at or before this point in field declaration. Expected identifier or other token.

Here is the record that I created for the above string type TypeAndWeight = { type: string; weight: string }

Disclaimer: I spent 15+ minutes reading open and closed issues to ensure that this question has not already been answered,

sanikolov commented 3 years ago

never mind, found answer here https://github.com/vsapronov/FSharp.Json#customizing-json-fields-names