Skip to content

Inconsistent handling of boolean (and other types) #1

@evan-king

Description

@evan-king

Why is true JSON but not false? Or 5 JSON but not 0? Of all the falsey values, only undefined cannot be stringified and is not valid JSON by any RFC/specification. true, 5, and 2.5 may or may not be valid JSON depending on what authority you cite, but I cannot conceive of a justifcation for including them while excluding null, false, 0, and 0.0.

The inconsistency seems problematic due to the use of this package within KOA itself. The behavior is wrong, yet deviation in custom middleware could cause as many bugs as it fixes.

(Update: I should acknowledge that there does need to be one value which indicates that there is no value, and that while undefined is most likely the clear winner, excluding null is likely to produce breaking changes in Koa with meaningful impact).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions