{"key1":"value1","key2":"value2","key3":"value3"}如何转换成{"Data":{"key1":"value1","key2":"value2","key3":"value3"}},用Java语言实现
时间: 2023-10-01 18:07:26 浏览: 79
spring-data-keyvalue-2.5.5-API文档-中文版.zip
{"key1":"value1","key2":"value2","key3":"value3"}可以通过以下Java代码实现转换成{"Data":{"key1":"value1","key2":"value2","key3":"value3"}}:
```java
import com.google.gson.JsonObject;
public class Main {
public static void main(String[] args) {
JsonObject jsonObject = new JsonObject();
JsonObject dataObject = new JsonObject();
jsonObject.addProperty("key1", "value1");
jsonObject.addProperty("key2", "value2");
jsonObject.addProperty("key3", "value3");
dataObject.add("Data", jsonObject);
System.out.println(dataObject);
}
}
```
阅读全文