Comments (5)
Just to be sure: the parser supports null
currently only when the current field is the name of a keyword field of the current data-type.
How about we just return nothing()
if no specific type is expected? And we could add support for null and non-null in case we expect Maybe[.]
from rascal.
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"))
from rascal.
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"
from rascal.
@tvdstorm Don't know what to do when writing these values back. Should the null values be written as null
again? Or just as they are? Support we have (#int:-1)
while reading integer nulls. Should -1
be written as null
again when we use the same nulls
map?
from rascal.
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.
from rascal.
Related Issues (20)
- Hover help with type information does not show column labels of relation types
- Just like #1958 parse errors by `parseModuleWithSpaces` function are not reported as Rascal exceptions but with Java stack traces HOT 1
- Anonymous variable `_` is allowed outside of patterns
- Default keyword fields will sometimes throw NPEs when the default value is the name of an (overloaded) function instead of a lambda.
- Use yellow or orange ANSI Background color for progress bar HOT 1
- Use parameter names to choose the right constructor for the JSON deserialization.
- Type checker misses type errors in the presence of local functions HOT 2
- Type inference of pattern variables in constructors sometimes fails HOT 3
- Typechecker permits duplicate formal keyword parameter names HOT 1
- IO::getResource is not rooted
- Implement + splices ("SplicePlus") HOT 2
- `type` constructor doesn't accept keyword parameters starting with `\` symbol HOT 6
- Type of generator leaks HOT 14
- Type checker infers `value` for known-type tuple wildcards in iterator HOT 2
- Ambiguity errors for productions annotated with a tag
- Errors with named parameters in function types HOT 2
- Ambiguity issues with 0.11.2 version of the vscode extension HOT 8
- Type constructor subtype issue?
- Remove `public` remove `public` modifier for public functions in the standard library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rascal.