[Cialug] What's a JSON Document?

jim kraai jimgkraai at gmail.com
Fri Aug 31 17:45:06 UTC 2018


:-D  I miss you Ken

dyac!  edit below, some implications \ some implementations

On Fri, Aug 31, 2018, 12:17 kristau <kristau at gmail.com> wrote:

> /me puts 3 things in his json files, just to piss off Jim. . .
> On Fri, Aug 31, 2018 at 10:05 AM jim kraai <jimgkraai at gmail.com> wrote:
> >
> > Crockford's original grammar that was on the front page of json. org a
> few
> > minutes ago in the top-right corner of the page as rendered in my desktop
> > chrome browser starts with json:\n\telement
> >
> > not elements, which is defined explicitly further down
> >
> > so one element per file
> >
> > but implementations deviate
> >
> > um, for the love of all that's technically holy, please only put one
> thing
> > per json file
> >
> > this is enforced implicitly by decoders that return a single decoded
> thing,
> > so even if one were to put in many top-level things, some implementations
> > return an array of decoded sub-things
> >
> > also some implications allow # and /**/comments which gives me mixed
> > feelings, but the comments are invariably dropped, which leads me to...
> >
> > here's a metric for evaluating behavior:  ignoring whitespace, does the
> > thing you started with equal decode(encode(thing))
> >
> > also ignoring whitespace, does encode(thing) in one language/environment
> > equal encode(thing) in another
> >
> > in different languages with different types you may get different results
> > because type hierarchies are rarely identical
> >
> > stopping there
> >
> >
> > On Thu, Aug 30, 2018, 17:03 David W. Body <davidbody at bigcreek.com>
> wrote:
> >
> > > A practical way to find out what is and isn't valid JSON is to use
> > > JavaScript's JSON.parse() and JSON.stringify() functions. You can do
> this
> > > in a node repl or in your browser's console.
> > >
> > > For example,
> > >
> > > > var p = JSON.parse("{}")
> > > undefined
> > > > p
> > > {}
> > > > var p = JSON.parse("{} {}")
> > > SyntaxError: Unexpected token { in JSON at position 3
> > > > JSON.stringify("hello world")
> > > '"hello world"'
> > > > var p = JSON.parse('"hello world"')
> > > undefined
> > > > p
> > > 'hello world'
> > >
> > > --David
> > >
> > >
> > > On Thu, Aug 30, 2018 at 1:25 PM, Dave Hala <dave at 58ghz.net> wrote:
> > >
> > > > I wonder if being loosely defined is actually problematic in
> practice?
> > > Has
> > > > anyone ever ran into a situation where exchanging data via json
> didn't
> > > > work?
> > > >
> > > > :) Dave
> > > >
> > > > On Thu, Aug 30, 2018 at 1:08 PM Scott Yates <Scott at yatesframe.com>
> > > wrote:
> > > >
> > > > > Since JSON often gets de-serialized, i tend to think of it as
> > > conforming
> > > > to
> > > > > a JavaScript "object".  Meaning "one object with many properties,
> or
> > > > nested
> > > > > objects/arrays"
> > > > >
> > > > > The problem (or advantage maybe) is that JSON is extremely loosely
> > > > defined
> > > > > (as you have noticed).
> > > > >
> > > > > On Thu, Aug 30, 2018 at 11:06 AM Todd Walton <tdwalton at gmail.com>
> > > wrote:
> > > > >
> > > > > > I know what JSON is. But I don't know what a JSON document is
> defined
> > > > as.
> > > > > > Wait, scratch that. It's not called a "document", it's called a
> > > "text".
> > > > > >
> > > > > > So I went off researching JSON this morning, and here are some
> > > things I
> > > > > > found:
> > > > > >
> > > > > > 1) ECMA defines it, of course, being it's derived from
> > > > > > JavaScript/ECMAScript. There's also an RFC: 8259.
> > > > > > 1a) RFC 8259 was published just last December!
> > > > > > 2)
> > > > > >
> > > > > https://www.ecma-international.org/publications/files/ECMA-
> > > > ST/ECMA-404.pdf
> > > > > > 3) https://tools.ietf.org/html/rfc8259
> > > > > > 4) ECMA says "JSON" is pronounced like "Jason". I prefer to say
> > > > > "jay-sawn".
> > > > > > 5) ECMA is a *lot* sloppier with their specifications than the
> IETF,
> > > > and
> > > > > > with the quality of their documentation.
> > > > > > 5a) <rant> ECMA! Shill for Microsoft. Skin disease. So on.
> </rant>
> > > > > > 6) "Hello, world" is a complete JSON text. Nothing says you have
> to
> > > > have
> > > > > > braces or brackets.
> > > > > > 7) Unicode is not actually strictly required.... (I did not
> expect
> > > > that.)
> > > > > >
> > > > > > So my question... Must a JSON text be *one* object or *one*
> array or
> > > > > *one*
> > > > > > unstructured string, number, or allowed constant? And must
> objects
> > > and
> > > > > > arrays be separated by a comma? Is the text between these dashed
> > > lines
> > > > a
> > > > > > conforming JSON text?:
> > > > > >
> > > > > > ------------
> > > > > > { "name": "Todd", "occupation": "scalawag" }
> > > > > > { "fruit": "orange", "delicious": true }
> > > > > > ------------
> > > > > >
> > > > > > --
> > > > > > Todd
> > > > > > _______________________________________________
> > > > > > Cialug mailing list
> > > > > > Cialug at cialug.org
> > > > > > http://cialug.org/mailman/listinfo/cialug
> > > > > >
> > > > > _______________________________________________
> > > > > Cialug mailing list
> > > > > Cialug at cialug.org
> > > > > http://cialug.org/mailman/listinfo/cialug
> > > > >
> > > >
> > > >
> > > > --
> > > > NIFCAP  -The Premier Client Intake System for Non-Profit
> Organizations.
> > > > _______________________________________________
> > > > Cialug mailing list
> > > > Cialug at cialug.org
> > > > http://cialug.org/mailman/listinfo/cialug
> > > >
> > > _______________________________________________
> > > Cialug mailing list
> > > Cialug at cialug.org
> > > http://cialug.org/mailman/listinfo/cialug
> > >
> > _______________________________________________
> > Cialug mailing list
> > Cialug at cialug.org
> > http://cialug.org/mailman/listinfo/cialug
>
>
>
> --
> Tired programmer
> Coding late into the night
> The core dump follows
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>


More information about the Cialug mailing list