I am trying to port a project to JavaScript but am running to a lot of issues due to the weird way that JavaScript works and the way JSON is converted to JavaScript. In particular, of all the methods and libraries I have found to parse JSON in JavaScript, they all fail a simple test - all the elements in this array must have distinct types (or be able to identify the original distinct types):
[
"",
0,
0.0,
{},
[],
false,
null
]
Many parsers cannot give me the difference between 0 and 0.0, and some cannot tell the difference between {} and [], and some just give the JavaScript literal null for null instead of a wrapper. These are all important to being able to port my project - does anyone know of a good JavaScript library that fits these requirements? I keep coming across ones that are no good. If from any given node I can access the parent node, that's a helpful bonus, otherwise I can replicate the behavior.
I have very little experience in JavaScript and writing my own parser seems both redundant and difficult :\
Note: the project I am porting uses a C parser that, as you might guess, meets all the requirements.
EDIT: I don't need (or want) a 1:1 mapping of JSON to JavaScript objects. Wrapper objects would be preferable, but all the libraries I can find try to map 1:1.
I was under the impression that by putting the word "parser" in the title of this topic, I could somehow convey what I wanted to those who read the title.
EDIT: Sorry for being rudely sarcastic, I'm not liking JavaScript and I keep finding more reasons to dislike the way it works. I didn't mean to take it out on you, but honestly I thought I was clear.
but am running to a lot of issues due to the weird way that JavaScript works and the way JSON is converted to JavaScript
Wrapper objects would be preferable, but all the libraries I can find try to map 1:1.
typically parsers dont translate and thats what it sounded like you were trying to do (or at the very least interface it). they generate tokens that are later translated.