G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 10th, 2020 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.google.gson.Gson;
  2. import com.google.gson.JsonObject;
  3. import com.google.gson.JsonParser;
  4. import com.google.gson.stream.JsonReader;
  5.  
  6. import java.util.HashSet;
  7. import java.util.Iterator;
  8. import java.util.Set;
  9.  
  10. public class MyClass {
  11.     public static void main(String args[]) {
  12.         Gson gson = new Gson();
  13.         Set<String> availableData = new HashSet<>();
  14.         availableData.add("{\"id\":\"Id1\"}");
  15.         availableData.add("{\"id\":\"Id2\",\"title\":\"anyTitle\"}");
  16.         Iterator<String> itr = availableData.iterator();
  17.         while (itr.hasNext()) {
  18.             Data data = gson.fromJson(itr.next(), Data.class);
  19.             System.out.println(data.id + " " + data.title);
  20.         }
  21.     }
  22.    
  23.     public class Data {
  24.         public String id;
  25.         public String title;
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top