When I try and unmarshal this JSON object from the Microsoft Web Ngram API:
{"backoff": NaN, "cookie": "", "probabilities": [], "words": []}
I get the error: "invalid character 'N' looking for beginning of value"
I know that NaN isn't valid JSON but the data isn't mine and I need a way to parse it. Is there any easy way to do this in Go?
You could replace it with null (or 0 or whatever is acceptable):
b, err := ioutil.ReadAll(resp)
//check err
b = bytes.Replace(b, []byte(":NaN"), []byte(":null"), -1)
//json.Decode(b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With