Git Product home page Git Product logo

Comments (5)

jurgenvinju avatar jurgenvinju commented on July 18, 2024

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.

jurgenvinju avatar jurgenvinju commented on July 18, 2024
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.

jurgenvinju avatar jurgenvinju commented on July 18, 2024
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.

jurgenvinju avatar jurgenvinju commented on July 18, 2024

@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.

jurgenvinju avatar jurgenvinju commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.