Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'missing values' in JSON arrays #52

Closed
highnoon opened this issue Jan 29, 2013 · 7 comments
Closed

Add support for 'missing values' in JSON arrays #52

highnoon opened this issue Jan 29, 2013 · 7 comments

Comments

@highnoon
Copy link

Got question or request for Feature to be added.

I have json object that does not follow json standard.
Example
[,,"41513053","30120.00",]

I have no control over the json only that I receive it.
I understand why the developers did it. ( to preserve bandwith ).
[null,null,"41513053","30120.00",null]

So I get ' com.fasterxml.jackson.core.JsonParseException: Unexpected
character (',' (code 44)): expected a valid value (number, String,
array, object, 'true', 'false' or 'null')'

It would be a nice feature to except this as null value.
JsonParser.Feature.ALLOW_NULL_EMPTY_VALUES.

@cowtowncoder
Copy link
Member

I think someone earlier requested to allow optional trailing comma; although not sure what would be expected semantics. With this change, it would result in a null value there.

This might be easy enough to support, either way; and perhaps even have separate features (allow empty values in arrays as nulls; allow extra trailing comma).

@valodzka
Copy link

valodzka commented Mar 6, 2013

+1 for this feature, I see in quite often in different JSON APIs.

Note that javascript handles such cases quite inconsistent:

[,,1,,]

Will be interpreted as:

[undefined,undefined,1,undefined]

@bfg
Copy link

bfg commented Sep 10, 2013

+1

@cburroughs
Copy link

Got here from http://jira.codehaus.org/browse/JACKSON-618

Specifically for a trailing command I would expect it to be ignored with some sort of ALLOW_TRAILING_COMMA option. I don't have any expectations for the [,,,"foo",,,] shorthand.

@cowtowncoder
Copy link
Member

I think we need a separate issue for ALLOW_TRAILING_COMMA, mostly since its implementation would be easier, and I think it would cover most of actual need. I read somewhere that this is actually top feature request for JSON format itself by some (I would have guessed comments personally so was surprised).

Even with trailing comma, there is question of semantics -- I am guessing that most would consider it something to basically ignore, but theoretical alternative would be to consider it a short-hand for ",null" construct. But then again, that would only work for arrays and not JSON Objects, so it would not be consistent.

@cburroughs
Copy link

Fair enough, trailing case broken off to : #118

@cowtowncoder
Copy link
Member

I'll close this in favor of #117 and #118, as they cover two aspects of this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants