Examples of JsonFactory


Examples of com.fasterxml.jackson.core.JsonFactory

public class EJsonTests {

  @Test
  public void test_map_simple() throws IOException {
   
    JsonFactory factory = new JsonFactory();
   
    String jsonInput = "{\"name\":\"rob\",\"age\":12}";

    JsonParser jsonParser = factory.createParser(jsonInput);

    Object result = EJson.parse(jsonParser);
   
    Assert.assertTrue(result instanceof Map);
    Map<?,?> map = (Map<?,?>)result;
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonFactory

  }

  @Test
  public void test_parseObject() throws IOException {

    JsonFactory factory = new JsonFactory();

    String jsonInput = "{\"name\":\"rob\",\"age\":12}";

    JsonParser jsonParser = factory.createParser(jsonInput);

    Object result = EJson.parseObject(jsonParser);

    Assert.assertTrue(result instanceof Map);
    Map<?,?> map = (Map<?,?>)result;
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonFactory

  @Test
  public void test_list_jsonParser() throws IOException {

    String jsonInput = "[\"name\",\"rob\",12,13]";

    JsonFactory jsonFactory = new JsonFactory();
    JsonParser parser = jsonFactory.createParser(jsonInput);

    List<Object> list = EJson.parseList(parser);

    Assert.assertEquals(4, list.size());
    Assert.assertEquals("name", list.get(0));
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonFactory

            }
        });

        Analyzer idx = newAnalyzer(srcpath, inclpaths);
        idx.multilineFunType = true;
        JsonFactory jsonFactory = new JsonFactory();
        JsonGenerator symJson = jsonFactory.createGenerator(symOut);
        JsonGenerator refJson = jsonFactory.createGenerator(refOut);
        JsonGenerator docJson = jsonFactory.createGenerator(docOut);
        JsonGenerator[] allJson = {symJson, refJson, docJson};
        for (JsonGenerator json : allJson) {
            json.writeStartArray();
        }
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonFactory

public class WriteJsonTest {

  @Test
  public void test_push() throws IOException {

    JsonFactory jsonFactory = new JsonFactory();
    JsonGenerator generator = jsonFactory.createGenerator(new StringWriter());

    PathProperties pathProperties = PathProperties.parse("id,status,name,customer(id,name,address(street,city)),orders(qty,product(sku,prodName))");
    WriteJson writeJson = new WriteJson(null, generator, pathProperties);

    WriteJson.WriteBean rootLevel = writeJson.createWriteBean(null, null);
View Full Code Here

Examples of com.google.api.client.json.JsonFactory

      + "\"token_type\":\"example\",\"expires_in\":3600,"
      + "\"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\","
      + "\"example_parameter\":\"example_value\"}";

  public void test() throws Exception {
    JsonFactory jsonFactory = new JacksonFactory();
    TokenResponse response = jsonFactory.fromString(JSON, TokenResponse.class);
    assertEquals("2YotnFZFEjr1zCsicMWpAA", response.getAccessToken());
    assertEquals("example", response.getTokenType());
    assertEquals(3600L, response.getExpiresInSeconds().longValue());
    assertEquals("tGzv3JOkF0XG5Qx2TlKWIA", response.getRefreshToken());
    assertEquals("example_value", response.get("example_parameter"));
View Full Code Here

Examples of com.google.api.client.json.JsonFactory

  private static final String JSON = "{\"error\":\"invalid_request\","
      + "\"error_uri\":\"http://www.example.com/error\","
      + "\"error_description\":\"error description\"}";

  public void test() throws Exception {
    JsonFactory jsonFactory = new JacksonFactory();
    TokenErrorResponse response = jsonFactory.fromString(JSON, TokenErrorResponse.class);
    assertEquals("invalid_request", response.getError());
    assertEquals("http://www.example.com/error", response.getErrorUri());
    assertEquals("error description", response.getErrorDescription());
  }
View Full Code Here

Examples of org.apache.wink.json4j.compat.JSONFactory

     */
    public void test_getDoubleNegative() {
        Exception ex = null;
        try {
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONArray jArray = factory.createJSONArray("[-1]");
            assertTrue(jArray.getDouble(0) == (double)-1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

Examples of org.codehaus.jackson.JsonFactory

    public Tests(int bufferSize, int depth, String input)
      throws IOException {
 
      this.depth = depth;
      byte[] in = input.getBytes("UTF-8");
      JsonFactory f = new JsonFactory();
      JsonParser p = f.createJsonParser(
          new ByteArrayInputStream(input.getBytes("UTF-8")));
     
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      Encoder cos = new BlockingBinaryEncoder(os, bufferSize);
      serialize(cos, p, os);
      cos.flush();
     
      byte[] bb = os.toByteArray();
      // dump(bb);
      this.input = DecoderFactory.defaultFactory().createBinaryDecoder(bb, null);
      this.parser =  f.createJsonParser(new ByteArrayInputStream(in));
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonFactory

  private final JsonNode data;
 
  public TestResolvingGrammarGenerator(String jsonSchema, String jsonData)
    throws IOException {
    this.schema = Schema.parse(jsonSchema);
    JsonFactory factory = new JsonFactory();
    ObjectMapper mapper = new ObjectMapper(factory);

    this.data = mapper.readTree(new StringReader(jsonData));
  }
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.