… | |
… | |
1612 | |
1612 | |
1613 | And after decoding the JSON text, you could walk the data |
1613 | And after decoding the JSON text, you could walk the data |
1614 | structure looking for arrays with a first element of |
1614 | structure looking for arrays with a first element of |
1615 | C<XU1peReLzT4ggEllLanBYq4G9VzliwKF>. |
1615 | C<XU1peReLzT4ggEllLanBYq4G9VzliwKF>. |
1616 | |
1616 | |
1617 | The same approach cna be used to create the tagged format with another |
1617 | The same approach can be used to create the tagged format with another |
1618 | encoder. First, you create an array with the magic string as first member, |
1618 | encoder. First, you create an array with the magic string as first member, |
1619 | the classname as second, and constructor arguments last, encode it as part |
1619 | the classname as second, and constructor arguments last, encode it as part |
1620 | of your JSON structure, and then: |
1620 | of your JSON structure, and then: |
1621 | |
1621 | |
1622 | $json =~ s/\[\s*"XU1peReLzT4ggEllLanBYq4G9VzliwKF"\s*,\s*("([^\\":,]+|\\.|::)*")\s*,/($1)[/g; |
1622 | $json =~ s/\[\s*"XU1peReLzT4ggEllLanBYq4G9VzliwKF"\s*,\s*("([^\\":,]+|\\.|::)*")\s*,/($1)[/g; |
1623 | |
1623 | |
1624 | Again, this has some limitations - the magic string must not be encoded |
1624 | Again, this has some limitations - the magic string must not be encoded |
1625 | with character escapes, and the constructor arguments must be non-empty. |
1625 | with character escapes, and the constructor arguments must be non-empty. |
|
|
1626 | |
|
|
1627 | |
|
|
1628 | =head1 RFC7158 |
|
|
1629 | |
|
|
1630 | Since this module was written, Google has written a new JSON RFC, RFC |
|
|
1631 | 7158. Unfortunately, this RFC breaks compatibility with both the original |
|
|
1632 | JSON specification on www.json.org and RFC4627. |
|
|
1633 | |
|
|
1634 | As far as I can see, you can get partial compatibility when parsing by |
|
|
1635 | using C<< ->allow_nonref >>. However, consider thew security implications |
|
|
1636 | of doing so. |
|
|
1637 | |
|
|
1638 | I haven't decided yet whether to break compatibility with RFC4627 by |
|
|
1639 | default (and potentially leave applications insecure), or change the |
|
|
1640 | default to follow RFC7158. |
|
|
1641 | |
1626 | |
1642 | |
1627 | =head1 THREADS |
1643 | =head1 THREADS |
1628 | |
1644 | |
1629 | This module is I<not> guaranteed to be thread safe and there are no |
1645 | This module is I<not> guaranteed to be thread safe and there are no |
1630 | plans to change this until Perl gets thread support (as opposed to the |
1646 | plans to change this until Perl gets thread support (as opposed to the |