ALLOW_UNQUOTED_FIELD_NAMES in jackon JSON library

Seems like Jackson with QUOTE_FIELD_NAMES in certain cases produces such output that it can't read itself even with ALLOW_UNQUOTED_FIELD_NAMES on. You will probably need to implement custom JsonParser for non-standard input parsing.

The problem is that you're generating non-standard JSON and there's no guarantees that client will handle it properly. However if you don't expose it outside your application(s) and care about size much you could parse/generate binary format like Jackson's Smile. See http://www.cowtowncoder.com/blog/archives/2010/09/entry_418.html (2.4).


Ok, Pingw33n's answer is pretty much correct I think. So: yes, you can use the feature; but it is rather heuristic -- since there is no specification as to how unquoted names should work (after all, JSON allows any and all characters for names!); or, what if any escape mechanism is to be used, it's anyone's guess as to what should be written or accepted.

In this particular case it is probably '-' character that causes an issue. It is not a legal part of Javascript name, which is the approximation Jackson uses.

One possible solution would be for Jackson to escape such characters in property names (I don't remember how it is done currently; if any name characters are quoted). If you can figure out a simple test case, you can file a Jira request-for-enchancement at Jackson Jira to get escaping added (and ensure parser can unescape the usual backslash version).


I believe the problem is related to Javascript sintax and not to Jackson nor JSON.

In Javascript a name is a letter optionally followed by one or more letters, digits, or underbars, so 90110a2e-febd-470f-afa4-cf7e890d31b9 is not a legal Javascript name.

The quotes around a property's name are optional if the name would be a legal JavaScript name and not a reserved word. So quotes are required around "first-name", but are optional around first_name.

BTW, if you are so concerned about JSON size why don't you gzip it?