ALLOW_UNQUOTED_FIELD_NAMES in jackon JSON library

后端 未结 4 839
时光说笑
时光说笑 2020-12-06 10:01

I\'m using the jackson library for serializing/deserializing to/from JSON. I need that this JSON has the smallest size as possible so I\'ve enabled the feature ALLOW_UNQUOT

4条回答
  •  一个人的身影
    2020-12-06 10:36

    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?

提交回复
热议问题