Package com.fasterxml.jackson.core

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


  }

  @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

  @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

            }
        });

        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

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

    return writeToStream(out);
  }

  public <S extends OutputStream> S writeToStream(S outputStream) {
    ObjectMapper mapper = dataFormat.getConfiguredObjectMapper();
    JsonFactory factory = mapper.getFactory();

    try {
      JsonGenerator generator = factory.createGenerator(outputStream);
      mapper.writeTree(generator, jsonNode);
    } catch (IOException e) {
      throw LOG.unableToWriteJsonNode(e);
    }
View Full Code Here

    return outputStream;
  }

  public <W extends Writer> W writeToWriter(W writer) {
    ObjectMapper mapper = dataFormat.getConfiguredObjectMapper();
    JsonFactory factory = mapper.getFactory();

    try {
      JsonGenerator generator = factory.createGenerator(writer);
      mapper.writeTree(generator, jsonNode);
    } catch (IOException e) {
      throw LOG.unableToWriteJsonNode(e);
    }
View Full Code Here

      if (!Strings.isEmpty(term))
      {
        StringWriter sw = new StringWriter();
        try
        {
          JsonGenerator gen = new JsonFactory().createGenerator(sw);

          AutocompleteJson value = null;
          Integer index = 0;
          List<Object> json = new ArrayList<Object>();
View Full Code Here

  {
    StringWriter sw = new StringWriter();

    try
    {
      JsonGenerator gen = new JsonFactory().createGenerator(sw);

      List<Object> json = new ArrayList<Object>();
      T defaultValue = AutocompleteComponent.this.getModelObject();
      AutocompleteJson value = null;
      Integer index = 0;
View Full Code Here

                    .bufferSize(batchSize).create();
        } catch (Exception ex) {
            throw new IOException("Could not instantiate BatchGraph wrapper", ex);
        }

        final JsonFactory factory = mapper.getFactory();
        final GraphSONUtility graphson = new GraphSONUtility(graph);

        try (JsonParser parser = factory.createParser(inputStream)) {
            if (parser.nextToken() != JsonToken.START_OBJECT)
                throw new IOException("Expected data to start with an Object");

            while (parser.nextToken() != JsonToken.END_OBJECT) {
                final String fieldName = parser.getCurrentName() == null ? "" : parser.getCurrentName();
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.core.JsonFactory

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.