JuliaIO / JSON.jl

JSON parsing and printing
Other
313 stars 101 forks source link

JSON boolean values not parsed as Julia Bool #275

Closed lewisl closed 5 years ago

lewisl commented 5 years ago

{"mybool": "true"}

will parse into a Julia Dict as

d["mybool"] "true"

with a type of String, naturally.

Since the JSON spec says to encode booleans as either "true" or "false", shouldn't the package recognize these and return valid Julian Bool?

I realize the performance implication is pretty terrible here because every string will need to be tested. I don't know if Python or Javascript returns language compatible booleans.

In my code I need to hard code tests for the presence of a key that I know will contain a boolean and convert the string to the corresponding bool value. This is kind of unfortunate--I won't always know in advance.

lewisl commented 5 years ago

Forget it. If you leave out the "" surrounding true and false in the raw text of the JSON file, it all works.