Package com.google.gson

Examples of com.google.gson.Gson


    userData.put("variables", getTemplates("variables"));
    userData.put("snippets", getTemplates("snippets"));
    userData.put("abbreviations", getTemplates("abbreviations"));
    userData.put("profiles", OutputProfile.allProfiles());
   
    Gson gson = new Gson();
    String payload = gson.toJson(userData);
    ctx.execJSFunction("javaLoadUserData", payload);
  }
View Full Code Here


          for (File f : files) {
            extFiles.add(f.getCanonicalPath());
          }
        } catch (Exception e) {}
       
        Gson gson = new Gson();
        ctx.execJSFunction("javaLoadExtensions", gson.toJson(extFiles));
      }
    }
  }
View Full Code Here

  }

  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

    page.title = resource.getName();
    page.content = resource.getContent();
    page.parent = resource.getParentName();
    switch (type) {
    case JSON:
      Gson gson = new Gson();
      String json = gson.toJson(page);
      return json;
    case XML:
      page.xmlns = "http://www.xwiki.org";
      XStream xstream = new XStream();
      xstream.alias("page", Page.class);
View Full Code Here

  protected String uri(String rootPath) {
    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

  protected String uri(String rootPath) {
    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());
    }
View Full Code Here

  }

  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

    page.text = resource.getContent();
    Entity entity = new Entity();
    entity.wiki_page = page;
    switch (type) {
    case JSON:
      Gson gson = new Gson();
      return gson.toJson(entity);
    case XML:
    default:
      return resource.getContent();
    }
  }
View Full Code Here

        final Relationship rel = rootNode.createRelationshipTo(n1, DynamicRelationshipType.withName("REL"));
        rel.setProperty("name","rel1");
        final CypherQueryExecutor.CypherResult result = cypherQueryExecutor.cypherQuery("start n=node("+rootNode.getId()+") match p=n-[r]->m return p,n,r,m", null);
        System.out.println(result);
        final List<Map<String,Object>> json = result.getJson();
        System.out.println(new Gson().toJson(json));
        assertEquals(1, json.size());
        final Map<String, Object> row = json.get(0);
        assertEquals(4, row.size());
        final Map node1 = (Map) row.get("n");
        assertEquals(1, node1.size());
View Full Code Here

    @Test
    public void testMergeGeoff() throws Exception {
        final Map map = neo4jService.mergeGeoff("(0) {\"foo\":\"bar\"}");
        assertEquals(MapUtil.map("foo", "bar"),map.get("(0)"));
        assertEquals("{\"(0)\":{\"foo\":\"bar\"}}",new Gson().toJson(map));
    }
View Full Code Here

TOP

Related Classes of com.google.gson.Gson

Copyright © 2018 www.massapicom. 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.