Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5.  
  6. import com.google.gson.Gson;
  7.  
  8. public class test {
  9.  
  10. public class Bloque {
  11.  
  12. Item items;
  13.  
  14. public Bloque() {
  15.  
  16. }
  17.  
  18. public void setItems(Item items) {
  19. this.items = items;
  20. }
  21.  
  22. public Item getItems() {
  23. return this.items;
  24. }
  25.  
  26. }
  27.  
  28. public class Item {
  29.  
  30. private List<Map<String, List<Object>>> values;
  31.  
  32. public Item() {
  33.  
  34. }
  35.  
  36. public List<Map<String, List<Object>>> getValues() {
  37. return values;
  38. }
  39.  
  40. public void setValues(List<Map<String, List<Object>>> values) {
  41. this.values = values;
  42. }
  43. }
  44.  
  45. public static void main(String[] args) {
  46. String json = "{\"items\":{\"values\":[{\"cCodint\":[1820541]}, {\"cCodint2\":[\"1820541\"]}]}}";
  47.  
  48.  
  49. Gson gson = new Gson();
  50.  
  51. Bloque bloque = gson.fromJson(json, Bloque.class);
  52.  
  53. System.out.println(gson.toJson(bloque));
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement