I have the following record defined in F#
:
type ListingContent =
{ from : string
landlord_id : string
listing_id : string
location : string
name : string
pic_1_url : string
pic_2_url : string
pic_3_url : string
pic_4_url : string
pic_5_url : string
messages : Map<string, Map<string,MessageContent>>
postcode : string
price_per_night : string
to_date : string;
}
I am using the following code:
let listings_json = JsonConvert.DeserializeObject<Types.ListingContent>(html)
to parse the following JSON:
{
"from":"19/01/2018",
"landlord_id":"YMM45tgFFvYB7rx9PhC2TE5eW6D2",
"listing_id":"-L0pJmU9yj4hAocHjnrB",
"location":"Edinburgh",
"name":"dan",
"pic_1_url":"https://firebasestorage.googleapis.com/v0/b/....",
"pic_2_url":"https://firebasestorage.googleapis.com/v0/b/....",
"pic_3_url":"https://firebasestorage.googleapis.com/v0/b/....",
"pic_4_url":"https://firebasestorage.googleapis.com/v0/b/....",
"pic_5_url":"https://firebasestorage.googleapis.com/v0/b/....",
"postcode":"....",
"price_per_night":"£32",
"to":"19/01/2019"
}
This parses everything fine except the to
field, because I am using to_date
in my record, it parses to null
... to
is a keyword in F#
therefore I cannot use it in my record definition. I can't really change the JSON in the database at this point. Is there any workaround around this?