… | |
… | |
101 | |
101 | |
102 | package JSON::XS; |
102 | package JSON::XS; |
103 | |
103 | |
104 | use common::sense; |
104 | use common::sense; |
105 | |
105 | |
106 | our $VERSION = '2.28'; |
106 | our $VERSION = '2.32'; |
107 | our @ISA = qw(Exporter); |
107 | our @ISA = qw(Exporter); |
108 | |
108 | |
109 | our @EXPORT = qw(encode_json decode_json to_json from_json); |
109 | our @EXPORT = qw(encode_json decode_json to_json from_json); |
110 | |
110 | |
111 | sub to_json($) { |
111 | sub to_json($) { |
… | |
… | |
713 | calls). |
713 | calls). |
714 | |
714 | |
715 | JSON::XS will only attempt to parse the JSON text once it is sure it |
715 | JSON::XS will only attempt to parse the JSON text once it is sure it |
716 | has enough text to get a decisive result, using a very simple but |
716 | has enough text to get a decisive result, using a very simple but |
717 | truly incremental parser. This means that it sometimes won't stop as |
717 | truly incremental parser. This means that it sometimes won't stop as |
718 | early as the full parser, for example, it doesn't detect parenthese |
718 | early as the full parser, for example, it doesn't detect mismatched |
719 | mismatches. The only thing it guarantees is that it starts decoding as |
719 | parentheses. The only thing it guarantees is that it starts decoding as |
720 | soon as a syntactically valid JSON text has been seen. This means you need |
720 | soon as a syntactically valid JSON text has been seen. This means you need |
721 | to set resource limits (e.g. C<max_size>) to ensure the parser will stop |
721 | to set resource limits (e.g. C<max_size>) to ensure the parser will stop |
722 | parsing in the presence if syntax errors. |
722 | parsing in the presence if syntax errors. |
723 | |
723 | |
724 | The following methods implement this incremental parser. |
724 | The following methods implement this incremental parser. |
… | |
… | |
1255 | well - using C<eval> naively simply I<will> cause problems. |
1255 | well - using C<eval> naively simply I<will> cause problems. |
1256 | |
1256 | |
1257 | Another problem is that some javascript implementations reserve |
1257 | Another problem is that some javascript implementations reserve |
1258 | some property names for their own purposes (which probably makes |
1258 | some property names for their own purposes (which probably makes |
1259 | them non-ECMAscript-compliant). For example, Iceweasel reserves the |
1259 | them non-ECMAscript-compliant). For example, Iceweasel reserves the |
1260 | C<__proto__> property name for it's own purposes. |
1260 | C<__proto__> property name for its own purposes. |
1261 | |
1261 | |
1262 | If that is a problem, you could parse try to filter the resulting JSON |
1262 | If that is a problem, you could parse try to filter the resulting JSON |
1263 | output for these property strings, e.g.: |
1263 | output for these property strings, e.g.: |
1264 | |
1264 | |
1265 | $json =~ s/"__proto__"\s*:/"__proto__renamed":/g; |
1265 | $json =~ s/"__proto__"\s*:/"__proto__renamed":/g; |
… | |
… | |
1319 | that difficult or long) and finally make YAML compatible to it, and |
1319 | that difficult or long) and finally make YAML compatible to it, and |
1320 | educating users about the changes, instead of spreading lies about the |
1320 | educating users about the changes, instead of spreading lies about the |
1321 | real compatibility for many I<years> and trying to silence people who |
1321 | real compatibility for many I<years> and trying to silence people who |
1322 | point out that it isn't true. |
1322 | point out that it isn't true. |
1323 | |
1323 | |
1324 | Addendum/2009: the YAML 1.2 spec is still incomaptible with JSON, even |
1324 | Addendum/2009: the YAML 1.2 spec is still incompatible with JSON, even |
1325 | though the incompatibilities have been documented (and are known to |
1325 | though the incompatibilities have been documented (and are known to Brian) |
1326 | Brian) for many years and the spec makes explicit claims that YAML is a |
1326 | for many years and the spec makes explicit claims that YAML is a superset |
1327 | superset of JSON. It would be so easy to fix, but apparently, bullying and |
1327 | of JSON. It would be so easy to fix, but apparently, bullying people and |
1328 | corrupting userdata is so much easier. |
1328 | corrupting userdata is so much easier. |
1329 | |
1329 | |
1330 | =back |
1330 | =back |
1331 | |
1331 | |
1332 | |
1332 | |