-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parseJSON
does not support null
in JSON
#1987
Comments
Just to be sure: the parser supports How about we just return |
rascal>parseJSON(#map[str,value], "{\"bla\": null}")
map[str, value]: ("bla":"null"())
rascal>parseJSON(#map[str,value], "{\"bla\": null}", nulls=(#value:-1))
map[str, value]: ("bla":-1)
rascal>parseJSON(#map[str,Maybe[str]], "{\"bla\": null}")
map[str, Maybe[str]]: ("bla":nothing())
rascal>parseJSON(#map[str,Maybe[str]], "{\"bla\": \"foo\"}")
map[str, Maybe[str]]: ("bla":just("foo")) |
rascal>data Cons = cons(str bla = "null");
ok
rascal>parseJSON(#Cons, "{\"bla\": \"foo\"}")
Cons: cons(bla="foo")
rascal>parseJSON(#Cons, "{\"bla\": null}")
Cons: cons()
rascal>parseJSON(#Cons, "{\"bla\": null}").bla
str: "null" |
@tvdstorm Don't know what to do when writing these values back. Should the null values be written as |
Also improved error reporting while we are at it. All internal parse errors and malformedness in the Gson parser is lifted to a Rascal ParseError with the JSON path query to the position, and offset, lengths, line/col, and the diagnostic. |
Reproduce:
As Rascal does not support null, we need a sentinel value, but this cannot be chosen by the implementation. Suggestion: a keyword parameter specifying a custom value to use in case of
null
.The text was updated successfully, but these errors were encountered: