將扁平化的JSON屬性轉換爲嵌套的JSON

須要將以下JSONgit

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

轉換爲github

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

 

添加項目依賴json

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

 

而後一行代碼搞定less

String nestJson = JsonUnflattener.unflatten(json);

 

項目地址:https://github.com/FasterXML/jacksonspa

相關文章
相關標籤/搜索