将扁平化的JSON属性转换为嵌套的JSON

需要将如下JSON

{"a":"a","b":"b","c.e":"e","c.f":"f"}

转换为

{"a":"a","b":"b","c":{"e":"e","f":"f"} 

 

添加项目依赖

<dependency>
    <groupId>com.github.wnameless</groupId>
    <artifactId>json-flattener</artifactId>
    <version>0.6.0</version>
    <scope>test</scope>
</dependency>

 

然后一行代码搞定

String nestJson = JsonUnflattener.unflatten(json);

 

项目地址:https://github.com/FasterXML/jackson

posted @ 2019-06-21 19:45  ido  阅读(1222)  评论(0编辑  收藏  举报