将扁平化的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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM