Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.MappingJsonFactory


  @SuppressWarnings("unchecked")
  public JsonWrapper(String content) throws Exception {
    this.content = content;
    try {
      target = new MappingJsonFactory().createJsonParser(content.replace("\\","/")).readValueAs(Map.class);
    } catch (JsonParseException e) {
      throw new JsonMappingException("Cannot create wrapper for:\n"+content, e);
    }
    context = new StandardEvaluationContext();
    context.addPropertyAccessor(new MapAccessor());
View Full Code Here


  private final Map<String, Object> target;

  @SuppressWarnings("unchecked")
  public JsonWrapper(String content) throws Exception {
    target = new MappingJsonFactory().createJsonParser(content).readValueAs(Map.class);
    context = new StandardEvaluationContext();
    context.addPropertyAccessor(new MapAccessor());
    parser = new SpelExpressionParser();
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    return mapper.valueToTree(this);
  }
     
  public static <T> T fromJson(byte[] in, Class<T> clazz) {
     MappingJsonFactory jsonFactory = new MappingJsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
     try {
      JsonParser jp = jsonFactory.createJsonParser(in);
      return jp.readValueAs(clazz);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

      throw new RuntimeException(e);
    }
  }
 
  public static <T> T fromJson(InputStream in, Class<T> clazz) {
     MappingJsonFactory jsonFactory = new MappingJsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
     try {
      JsonParser jp = jsonFactory.createJsonParser(in);
      return jp.readValueAs(clazz);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
   
View Full Code Here

public class JsonMarshaller<T extends Object> implements DynamoDBMarshaller<T> {

    @Override
    public String marshall(T obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            StringWriter output = new StringWriter();
            JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(output);
            jsonGenerator.writeObject(obj);
            return output.toString();
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
View Full Code Here

    }

    @Override
    public T unmarshall(Class<T> clazz, String obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
            return jsonParser.readValueAs(clazz);
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        WebClient client = WebClient.create(endpointUrl + "/hello/jsonBean", providers);
        Response r = client.accept("application/json")
            .type("application/json")
            .post(inputBean);
        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
        MappingJsonFactory factory = new MappingJsonFactory();
        JsonParser parser = factory.createJsonParser((InputStream)r.getEntity());
        JsonBean output = parser.readValueAs(JsonBean.class);
        assertEquals("Maple", output.getVal2());
    }
View Full Code Here

      return values;
   }
  
   public static Map<String, Object> jsonToStorageEntry(String fmJson, boolean isDelete) throws IOException {
      Map<String, Object> entry = new HashMap<String, Object>();
      MappingJsonFactory f = new MappingJsonFactory();
      JsonParser jp;
     
      try {
          jp = f.createJsonParser(fmJson);
      } catch (JsonParseException e) {
          throw new IOException(e);
      }
     
      jp.nextToken();
View Full Code Here

  public static EObject fromJson(String jsonTxt, EClass eClass) throws IOException {
    return new JsonMapper().from(jsonTxt, eClass);
  }
 
  public EObject from(String jsonTxt, EClass eClass) throws IOException {
    JsonFactory f = new MappingJsonFactory();
    JsonParser jp = f.createJsonParser(jsonTxt.getBytes());
    return from(jp, eClass);
  }
View Full Code Here

 
  public String to(EObject eObj) throws IOException {
    StringWriter result = new StringWriter();
    JsonGenerator jg = null;
   
    jg = new MappingJsonFactory().createJsonGenerator(result);
    to(eObj, jg);
    jg.flush();
   
    return result.toString();
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.MappingJsonFactory

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.