Examples of Gson


Examples of com.google.gson.Gson

        return l;
    }

    // NOTE: needs to be duplicated logic due to Java erasure of generic types
    public List<Blog> getBlogs() {
        Gson gson = gsonParser();
        JsonObject object = (JsonObject) response;
        List<Blog> l = gson.fromJson(object.get("blogs"), new TypeToken<List<Blog>>() {}.getType());
        for (Blog e : l) { e.setClient(client); }
        return l;
    }
View Full Code Here

Examples of com.google.gson.Gson

    /**
     **
     **/

    private <T extends Resource> T get(String field, Class<T> k) {
        Gson gson = gsonParser();
        JsonObject object = (JsonObject) response;
        T e = gson.fromJson(object.get(field).toString(), k);
        e.setClient(client);
        return e;
    }
View Full Code Here

Examples of com.google.gson.Gson

        Map<String, String> flat = new HashMap<String, String>();
        flat.put("type", "link");
        flat.put("title", title);
        flat.put("description", desc);
        flat.put("url", url);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (LinkPost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

        flat.put("artist", artistName);
        flat.put("album_art", albumArtUrl);
        flat.put("year", year);
        flat.put("track_number", trackNumber);
        flat.put("player", embedCode);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (AudioPost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

        flat.put("title", title);
        flat.put("body", body);
        flat.put("note_count", noteCount);
        flat.put("reblogged_from_id", rebloggedFromId);
        flat.put("reblogged_from_name", rebloggedFromName);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (TextPost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

        flat.put("type", "answer");
        flat.put("asking_url", askingUrl);
        flat.put("asking_name", askingName);
        flat.put("question", question);
        flat.put("answer", answer);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (AnswerPost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

        Map<String, String> flat = new HashMap<String, String>();
        flat.put("type", "chat");
        flat.put("title", title);
        flat.put("body", body);
        flat.put("dialogue", dialogue);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (ChatPost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

    @Before
    public void setup() {
        Map<String, Object> flat = new HashMap<String, Object>();
        flat.put("type", "nonexistent");
        flat.put("id", id);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here

Examples of com.google.gson.Gson

        flat.put("updated", updated);
        flat.put("ask", ask);
        flat.put("ask_anon", ask_anon);
        flat.put("followers", followers);

        Gson gson = new Gson();
        blog = gson.fromJson(flatSerialize(flat), Blog.class);
        blog.setName(blog.getName());
        client = mock(JumblrClient.class);
        blog.setClient(client);
    }
View Full Code Here

Examples of com.google.gson.Gson

        flat.put("text", text);
        flat.put("author", author);
        flat.put("slug", slug);
        flat.put("notes", notes);
        flat.put("note_count", 123);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (QuotePost) gson.fromJson(flatSerialize(flat), Post.class);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.