… | |
… | |
636 | calls). |
636 | calls). |
637 | |
637 | |
638 | JSON::XS will only attempt to parse the JSON text once it is sure it has |
638 | JSON::XS will only attempt to parse the JSON text once it is sure it has |
639 | enough text to get a decisive result, using a very simple but truly |
639 | enough text to get a decisive result, using a very simple but truly |
640 | incremental parser. This means that it sometimes won't stop as early as |
640 | incremental parser. This means that it sometimes won't stop as early as |
641 | the full parser, for example, it doesn't detect parenthese mismatches. |
641 | the full parser, for example, it doesn't detect mismatched parentheses. |
642 | The only thing it guarantees is that it starts decoding as soon as a |
642 | The only thing it guarantees is that it starts decoding as soon as a |
643 | syntactically valid JSON text has been seen. This means you need to set |
643 | syntactically valid JSON text has been seen. This means you need to set |
644 | resource limits (e.g. "max_size") to ensure the parser will stop parsing |
644 | resource limits (e.g. "max_size") to ensure the parser will stop parsing |
645 | in the presence if syntax errors. |
645 | in the presence if syntax errors. |
646 | |
646 | |
… | |
… | |
1143 | characters as well - using "eval" naively simply *will* cause problems. |
1143 | characters as well - using "eval" naively simply *will* cause problems. |
1144 | |
1144 | |
1145 | Another problem is that some javascript implementations reserve some |
1145 | Another problem is that some javascript implementations reserve some |
1146 | property names for their own purposes (which probably makes them |
1146 | property names for their own purposes (which probably makes them |
1147 | non-ECMAscript-compliant). For example, Iceweasel reserves the |
1147 | non-ECMAscript-compliant). For example, Iceweasel reserves the |
1148 | "__proto__" property name for it's own purposes. |
1148 | "__proto__" property name for its own purposes. |
1149 | |
1149 | |
1150 | If that is a problem, you could parse try to filter the resulting JSON |
1150 | If that is a problem, you could parse try to filter the resulting JSON |
1151 | output for these property strings, e.g.: |
1151 | output for these property strings, e.g.: |
1152 | |
1152 | |
1153 | $json =~ s/"__proto__"\s*:/"__proto__renamed":/g; |
1153 | $json =~ s/"__proto__"\s*:/"__proto__renamed":/g; |
… | |
… | |
1201 | (which is not that difficult or long) and finally make YAML |
1201 | (which is not that difficult or long) and finally make YAML |
1202 | compatible to it, and educating users about the changes, instead of |
1202 | compatible to it, and educating users about the changes, instead of |
1203 | spreading lies about the real compatibility for many *years* and |
1203 | spreading lies about the real compatibility for many *years* and |
1204 | trying to silence people who point out that it isn't true. |
1204 | trying to silence people who point out that it isn't true. |
1205 | |
1205 | |
1206 | Addendum/2009: the YAML 1.2 spec is still incomaptible with JSON, |
1206 | Addendum/2009: the YAML 1.2 spec is still incompatible with JSON, |
1207 | even though the incompatibilities have been documented (and are |
1207 | even though the incompatibilities have been documented (and are |
1208 | known to Brian) for many years and the spec makes explicit claims |
1208 | known to Brian) for many years and the spec makes explicit claims |
1209 | that YAML is a superset of JSON. It would be so easy to fix, but |
1209 | that YAML is a superset of JSON. It would be so easy to fix, but |
1210 | apparently, bullying and corrupting userdata is so much easier. |
1210 | apparently, bullying people and corrupting userdata is so much |
|
|
1211 | easier. |
1211 | |
1212 | |
1212 | SPEED |
1213 | SPEED |
1213 | It seems that JSON::XS is surprisingly fast, as shown in the following |
1214 | It seems that JSON::XS is surprisingly fast, as shown in the following |
1214 | tables. They have been generated with the help of the "eg/bench" program |
1215 | tables. They have been generated with the help of the "eg/bench" program |
1215 | in the JSON::XS distribution, to make it easy to compare on your own |
1216 | in the JSON::XS distribution, to make it easy to compare on your own |