… | |
… | |
1153 | my $yaml = $to_yaml->encode ($ref) . "\n"; |
1153 | my $yaml = $to_yaml->encode ($ref) . "\n"; |
1154 | |
1154 | |
1155 | This will *usually* generate JSON texts that also parse as valid YAML. |
1155 | This will *usually* generate JSON texts that also parse as valid YAML. |
1156 | Please note that YAML has hardcoded limits on (simple) object key |
1156 | Please note that YAML has hardcoded limits on (simple) object key |
1157 | lengths that JSON doesn't have and also has different and incompatible |
1157 | lengths that JSON doesn't have and also has different and incompatible |
1158 | unicode handling, so you should make sure that your hash keys are |
1158 | unicode character escape syntax, so you should make sure that your hash |
1159 | noticeably shorter than the 1024 "stream characters" YAML allows and |
1159 | keys are noticeably shorter than the 1024 "stream characters" YAML |
1160 | that you do not have characters with codepoint values outside the |
1160 | allows and that you do not have characters with codepoint values outside |
1161 | Unicode BMP (basic multilingual page). YAML also does not allow "\/" |
1161 | the Unicode BMP (basic multilingual page). YAML also does not allow "\/" |
1162 | sequences in strings (which JSON::XS does not *currently* generate, but |
1162 | sequences in strings (which JSON::XS does not *currently* generate, but |
1163 | other JSON generators might). |
1163 | other JSON generators might). |
1164 | |
1164 | |
1165 | There might be other incompatibilities that I am not aware of (or the |
1165 | There might be other incompatibilities that I am not aware of (or the |
1166 | YAML specification has been changed yet again - it does so quite often). |
1166 | YAML specification has been changed yet again - it does so quite often). |
… | |
… | |
1182 | of its proponents, I would kindly suggest reading the JSON spec |
1182 | of its proponents, I would kindly suggest reading the JSON spec |
1183 | (which is not that difficult or long) and finally make YAML |
1183 | (which is not that difficult or long) and finally make YAML |
1184 | compatible to it, and educating users about the changes, instead of |
1184 | compatible to it, and educating users about the changes, instead of |
1185 | spreading lies about the real compatibility for many *years* and |
1185 | spreading lies about the real compatibility for many *years* and |
1186 | trying to silence people who point out that it isn't true. |
1186 | trying to silence people who point out that it isn't true. |
|
|
1187 | |
|
|
1188 | Addendum/2009: the YAML 1.2 spec is still incomaptible with JSON, |
|
|
1189 | even though the incompatibilities have been documented (and are |
|
|
1190 | known to Brian) for many years and the spec makes explicit claims |
|
|
1191 | that YAML is a superset of JSON. It would be so easy to fix, but |
|
|
1192 | apparently, bullying and corrupting userdata is so much easier. |
1187 | |
1193 | |
1188 | SPEED |
1194 | SPEED |
1189 | It seems that JSON::XS is surprisingly fast, as shown in the following |
1195 | It seems that JSON::XS is surprisingly fast, as shown in the following |
1190 | tables. They have been generated with the help of the "eg/bench" program |
1196 | tables. They have been generated with the help of the "eg/bench" program |
1191 | in the JSON::XS distribution, to make it easy to compare on your own |
1197 | in the JSON::XS distribution, to make it easy to compare on your own |