JSON.stringify(undefined)
# Barry van Oudtshoorn (13 years ago)
I would assume that this is because the JSON grammar doesn't include "undefined" as an acceptable value -- JSON.stringify({foo:undefined}) returns "{}". Perhaps JSON.stringify(undefined) should, however, return "" -- in my view, this would make more sense.
I would assume that this is because the JSON grammar doesn't include "undefined" as an acceptable value -- JSON.stringify({foo:undefined}) returns "{}". Perhaps JSON.stringify(undefined) should, however, return "" -- in my view, this would make more sense. On 16/07/12 10:48, Axel Rauschmayer wrote: > ... returns undefined. Shouldn't it be "undefined"? > > -- > Dr. Axel Rauschmayer > axel at rauschma.de <mailto:axel at rauschma.de> > > home: rauschma.de <http://rauschma.de> > twitter: twitter.com/rauschma <http://twitter.com/rauschma> > blog: 2ality.com <http://2ality.com> > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -- Barry van Oudtshoorn www.barryvan.com.au -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120716/2aff0b38/attachment-0001.html>
# Tim Smart (13 years ago)
Calling JSON.stringify(undefined) is essentially the same as calling JSON.stringify()
null
is a better representation of a 'empty' value.
Tim.
Calling JSON.stringify(undefined) is essentially the same as calling JSON.stringify() `null` is a better representation of a 'empty' value. Tim. On Mon, Jul 16, 2012 at 12:57:13PM +0800, Barry van Oudtshoorn wrote: > I would assume that this is because the JSON grammar doesn't include > "undefined" as an acceptable value -- > JSON.stringify({foo:undefined}) returns "{}". Perhaps > JSON.stringify(undefined) should, however, return "" -- in my view, > this would make more sense. > > On 16/07/12 10:48, Axel Rauschmayer wrote: > >... returns undefined. Shouldn't it be "undefined"? > > > >-- > >Dr. Axel Rauschmayer > >axel at rauschma.de <mailto:axel at rauschma.de> > > > >home: rauschma.de <http://rauschma.de> > >twitter: twitter.com/rauschma <http://twitter.com/rauschma> > >blog: 2ality.com <http://2ality.com> > > > > > > > >_______________________________________________ > >es-discuss mailing list > >es-discuss at mozilla.org > >https://mail.mozilla.org/listinfo/es-discuss > > -- > Barry van Oudtshoorn > www.barryvan.com.au > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss
# Axel Rauschmayer (13 years ago)
Barry, Tim: Right, undefined is not valid JSON.
Barry, Tim: Right, undefined is not valid JSON. Thanks! On Jul 16, 2012, at 6:57 , Barry van Oudtshoorn wrote: > I would assume that this is because the JSON grammar doesn't include "undefined" as an acceptable value -- JSON.stringify({foo:undefined}) returns "{}". Perhaps JSON.stringify(undefined) should, however, return "" -- in my view, this would make more sense. > > On 16/07/12 10:48, Axel Rauschmayer wrote: >> ... returns undefined. Shouldn’t it be "undefined"? >> >> -- >> Dr. Axel Rauschmayer >> axel at rauschma.de >> >> home: rauschma.de >> twitter: twitter.com/rauschma >> blog: 2ality.com >> >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > -- > Barry van Oudtshoorn > www.barryvan.com.au > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -- Dr. Axel Rauschmayer axel at rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120716/407129ef/attachment-0001.html>
... returns undefined. Shouldn’t it be "undefined"?