Skip Menu |

This queue is for tickets about the JSON-PP CPAN distribution.

Report information
The Basics
Id: 98500
Status: resolved
Priority: 0/
Queue: JSON-PP

People
Owner: Nobody in particular
Requestors: davido [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Support for RFC 7159: Naked values.
To support RFC-7159, JSON should allow values to exist at the top level, outside of arrays or objects. Examples: my $jn = encode_json(1); # 1 my $js = encode_json("Hello world"); # "Hello world" my $string = decode_json('"Hello world"'); # Hello world my $number = decode_json('1'); # 1 The "allow_nonref" configuration option effectively enables this feature for the object-oriented interface to the JSON module, so the code seems to already exist to support RFC-7159. There could be a few possibilities on how this might be handled: 1: Update the docs to state that JSON supports RFC-7159, and change the default behavior to "allow_nonref" enabled. Also document that for RFC-4627 behavior, it is necessary to set "allow_nonref" to disabled. 2: Leave the existing defaults, but update the docs to suggest that for RFC-7159 compliant parsing / encoding, the allow_nonref feature should be turned on. 3: (This could co-exist with either solution 1 or 2): Add an "rfc7159($enable)", and a mutually exclusive "rfc4627($enable)" tag, and throw an exception if both are used at the same time in conflicting ways, or if allow_nonref is used in a conflicting way at the same time. ...just some ideas. Ultimately it's probably best for the JSON family of modules to simply adopt the new standard. It's unlikely to break any existing usage. 3:
On Mon Sep 01 00:58:39 2014, DAVIDO wrote: Show quoted text
> To support RFC-7159, JSON should allow values to exist at the top > level, outside of arrays or objects.
...should also mention; this RFC-7159 is compatible with ECMA-404: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf The wording is a little different, but the gist is that values are the top level of the grammar now, and a value can be an array, an object, a string, a number, or 'null', 'false', 'true'.
On Mon Sep 01 17:02:12 2014, DAVIDO wrote: Show quoted text
> On Mon Sep 01 00:58:39 2014, DAVIDO wrote:
> > To support RFC-7159, JSON should allow values to exist at the top > > level, outside of arrays or objects.
> > ...should also mention; this RFC-7159 is compatible with ECMA-404: > http://www.ecma-international.org/publications/files/ECMA-ST/ECMA- > 404.pdf > > The wording is a little different, but the gist is that values are the > top level of the grammar now, and a value can be an array, an object, > a string, a number, or 'null', 'false', 'true'.
Released JSON::PP 4.00 that allows nonref by default. Thanks.