Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.viewWriter()


        if (annotations != null && annotations.length > 0) {
            viewToUse = _findView(mapper, annotations);
        }
        if (viewToUse != null) {
            // TODO: change to use 'writerWithType' for 2.0 (1.9 could use, but let's defer)
            ObjectWriter viewWriter = mapper.viewWriter(viewToUse);
            // [JACKSON-245] Allow automatic JSONP wrapping
            if (_jsonpFunctionName != null) {
                viewWriter.writeValue(jg, new JSONPObject(this._jsonpFunctionName, value, rootType));
            } else if (rootType != null) {
                // TODO: change to use 'writerWithType' for 2.0 (1.9 could use, but let's defer)
View Full Code Here


  public final <_Object_ extends Object> Object encode (final _Object_ object, final Class<_Object_> clasz)
  {
    try {
      final ObjectMapper mapper = new ObjectMapper ();
      final TokenBuffer buffer = new TokenBuffer (mapper);
      mapper.viewWriter (clasz).writeValue (buffer, object);
      final JsonParser parser = buffer.asParser ();
      final JsonNode node = mapper.readTree (parser);
      parser.close ();
      final Object data = this.transformFromNode (node);
      return (data);
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.