is-json icon indicating copy to clipboard operation
is-json copied to clipboard

add null as acceptable json

Open fl0w opened this issue 8 years ago • 7 comments

https://github.com/koajs/koa/issues/998

fl0w avatar Jul 24 '17 00:07 fl0w

false, 0 and "" (empty string) are also valid JSON but this function will fail to validate them.

fardelian avatar Aug 01 '17 20:08 fardelian

@fardelian this was specifically for a feature request in Koa (referenced in original comment). Not sure it's supposed to pass all those.

fl0w avatar Aug 01 '17 20:08 fl0w

@fl0w I still think you update the commit to support all the values. I got to this PR from that feature request but I'd consider it a bug report. The complete fix would be to support all those values.

fardelian avatar Aug 01 '17 20:08 fardelian

@fardelian in that issue the consensus amongst Koa core members was to add null, and I needed this updated to complete a fix that specific Koa issue, not to make this spec compliant.

fl0w avatar Aug 01 '17 20:08 fl0w

@fl0w why not adding false, "" and 0 as well? Someone may come across the same issue I'm having with null value in returning "" 0 or false . This way we can be sure koa is correctly returning any valid json value: up to the developer to properly handle it.

damianobarbati avatar Aug 31 '17 14:08 damianobarbati

I think this should be an option. though these are valid JSON bodies, it doesn't make sense in the real world to send these as HTTP bodies

jonathanong avatar Sep 11 '17 17:09 jonathanong

@jonathanong, please close this PR and merge/close all other PRs.

3imed-jaberi avatar Feb 19 '22 20:02 3imed-jaberi