Examples of fromJson()


Examples of com.google.gson.Gson.fromJson()

        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);
    }

    @Test
    public void testReaders() {
        assertEquals(source, post.getSource());
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

        flat.put("likes", likes);
        flat.put("blogs", blogs);
        flat.put("default_post_format", default_post_format);

        Gson gson = new Gson();
        user = gson.fromJson(flatSerialize(flat), User.class);
    }

    @Test
    public void testReaders() {
        assertEquals(default_post_format, user.getDefaultPostFormat());
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

        flat.put("caption", caption);
        flat.put("width", width);
        flat.put("height", height);
        flat.put("photos", photos);
        Gson gson = new GsonBuilder().registerTypeAdapter(Post.class, new PostDeserializer()).create();
        post = (PhotoPost) gson.fromJson(flatSerialize(flat), Post.class);
    }

    @Test
    public void testReaders() {
        assertEquals(caption, post.getCaption());
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

  protected String text(String entity, Type type) {
    switch (type) {
    case JSON:
      Gson gson = new Gson();
      return gson.fromJson(entity, Page.class).content;
    case XML:
      XStream xstream = new XStream();
      xstream.alias("page", Page.class);
      xstream.ignoreUnknownElements();
      return ((Page) xstream.fromXML(entity)).content;
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    return format(INDEX_URI, rootPath);
  }

  private Collection<Page> parse(String entity) {
    Gson gson = new Gson();
    return gson.<Collection<Page>> fromJson(
        jsonMember(entity, "pageSummaries"),
        new TypeToken<Collection<Page>>() {
        }.getType());
  }
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    return format(INDEX_URI, rootPath);
  }

    private Collection<Page> parse(String entity) {
        Gson gson = new Gson();
        return gson.<Collection<Page>> fromJson(jsonMember(entity, "wiki_pages"),
                new TypeToken<Collection<Page>>() {
                }.getType());
    }

    private String jsonMember(String entity, String memberName) {
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

  protected String text(String entity, Type type) {
    switch (type) {
    case JSON:
      Gson gson = new Gson();
      return gson.fromJson(jsonMember(entity, "wiki_page"),
          WikiPage.class).text;
    case XML:
      XStream xstream = new XStream();
      xstream.alias("wiki_page", WikiPage.class);
      xstream.ignoreUnknownElements();
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    .enableComplexMapKeySerialization()
    .setDateFormat(DateFormat.LONG)
    .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
    .setVersion(1.0)
    .create();
    Object obj = gson.fromJson(src.getValue(), Object.class);
    try {
      return JSONReadingTypeVisitor.read(obj, values, store, start);
    }
    catch (IOException e) {
      throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    .setDateFormat(DateFormat.LONG)
    .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
    .setVersion(1.0)
    .create();
    System.err.println("fromJSON1:"+src.getValue());
    Object obj = gson.fromJson(src.getValue(), Object.class);
    System.err.println("fromJSON2:"+start);
    try {
      return JSONReadingTypeVisitor.read(obj, values, store, start);
    }
    catch (IOException e) {
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    /**
     * Save album via JSON API
     */
    private static void saveAlbumJson() {
        Gson gson = new Gson();
        Album album = gson.fromJson(new InputStreamReader(request.body), Album.class);
        album.replaceDuplicateArtist();
        album.save();
    }

    /**
 
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.