String input = "Vish,Path,123456789";
期望的输出为Json字符串,并且线程安全 = {"name":"Vish","surname":"Path","mobile":"123456789"}
我尝试使用
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
但是每次我创建新对象时 -
MappingObject[] studentArray = new MappingObject[1];
studentArray[0] = new MappingObject("Vish","Path","123456789");
我使用 split() 函数将这个逗号分隔的字符串进行了拆分。
System.out.println("JSON "+gson.toJson(studentArray));