Issue #18 resolved

primitive type can't be properly used

asdfMAN2
created an issue

I guess I found a bug.

If you use the primitive type and want to know either it is null, a boolean or a numeric, you check the words, for example if("false" == primitive.value). The advice just to check the first char is useless to me and I guess so for many C-programmers, because if a 4 Byte numeric is accidentially the ascii-representation of the word "null" or "true" it cannot be handled. Just checking the first char increases the set of numbers, in which errors occure, a lot. If You have any suggestion about this, please let me know.

Example: 0x6e756c6c is both, a valid integer and the "null" chars.

If it is my fault, please let me know which would be a proper solution for this problem.

if i didn't point out what the problem is, let me know and I will enlarge the description.

best regards, christian

Comments (3)

  1. Serge Zaitsev repo owner

    Yes, eloff is absolutely right. JSON string is all ASCII, so the number 123 is actually a string "123", or an array of bytes [0x31, 0x32, 0x33], so no collision here. Also, JSON doesn't allow to use hexadecimal form for numbers, so every number is decimal and starts with a digit (0-9) or a minus sign. You can see the proof on json.org. Other three possible primitives are "true", "false" and "null", they have different first character, and it is not an ascii number (0x30..0x39), so right, no ambiguity here. Closing as not an issue.

  2. Log in to comment