Apply variable name improvement from issue 385.
Fixes issue 385.
This commit is contained in:
parent
5acaee4ebc
commit
dce4e463d9
@ -23,8 +23,6 @@ import com.google.gson.JsonArray;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
public class RawCollectionsExample {
|
public class RawCollectionsExample {
|
||||||
public static final String json = "['hello',5,{name:'GREETINGS',source:'guest'}]";
|
|
||||||
|
|
||||||
static class Event {
|
static class Event {
|
||||||
private String name;
|
private String name;
|
||||||
private String source;
|
private String source;
|
||||||
@ -45,8 +43,8 @@ public class RawCollectionsExample {
|
|||||||
collection.add("hello");
|
collection.add("hello");
|
||||||
collection.add(5);
|
collection.add(5);
|
||||||
collection.add(new Event("GREETINGS", "guest"));
|
collection.add(new Event("GREETINGS", "guest"));
|
||||||
String json2 = gson.toJson(collection);
|
String json = gson.toJson(collection);
|
||||||
System.out.println("Using Gson.toJson() on a raw collection: " + json2);
|
System.out.println("Using Gson.toJson() on a raw collection: " + json);
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
JsonArray array = parser.parse(json).getAsJsonArray();
|
JsonArray array = parser.parse(json).getAsJsonArray();
|
||||||
String message = gson.fromJson(array.get(0), String.class);
|
String message = gson.fromJson(array.get(0), String.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user