yahoo / serialize-javascript

Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v1.9.0 creates invalid json by including undefined values

src-code opened this issue · comments

There seems to be a regression in v1.9.0 where objects with undefined values are being included in the json output, which is invalid. For example:

serialize({
  "foobar": undefined
});

Output:

{"foobar":undefined}

This is not valid json, and will fail when run through JSON.parse()

In v1.8.0 this worked correctly with the following output:

{}

Closing this as I guess it's intentional that this lib creates a superset of json

Could you reopen as this looks like a breaking change that might have warranted a major version bump.

Thanks for the quick fix @okuryu !