… | |
… | |
267 | ] |
267 | ] |
268 | { |
268 | { |
269 | "k1": "v1", |
269 | "k1": "v1", |
270 | "k2": "v2", <- this comma not normally allowed |
270 | "k2": "v2", <- this comma not normally allowed |
271 | } |
271 | } |
|
|
272 | |
|
|
273 | * shell-style '#'-comments |
|
|
274 | Whenever JSON allows whitespace, shell-style comments are |
|
|
275 | additionally allowed. They are terminated by the first |
|
|
276 | carriage-return or line-feed character, after which more |
|
|
277 | white-space and comments are allowed. |
|
|
278 | |
|
|
279 | [ |
|
|
280 | 1, # this comment not allowed in JSON |
|
|
281 | # neither this one... |
|
|
282 | ] |
272 | |
283 | |
273 | $json = $json->canonical ([$enable]) |
284 | $json = $json->canonical ([$enable]) |
274 | If $enable is true (or missing), then the "encode" method will |
285 | If $enable is true (or missing), then the "encode" method will |
275 | output JSON objects by sorting their keys. This is adding a |
286 | output JSON objects by sorting their keys. This is adding a |
276 | comparatively high overhead. |
287 | comparatively high overhead. |