需要将如下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);