_jsonFactory = new MappingJsonFactory(this); } else { _jsonFactory = jf;
public EObject from(String jsonTxt, EClass eClass) throws IOException { JsonFactory f = new MappingJsonFactory(); JsonParser jp = f.createJsonParser(jsonTxt.getBytes()); return from(jp, eClass); }
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(); }
_jsonFactory = new MappingJsonFactory(this); } else { _jsonFactory = jf;
public static Object deserializeFromJson(String json, Class valueType) { try { ObjectMapper mapper = new ObjectMapper(); MappingJsonFactory jsonFactory = new MappingJsonFactory(); JsonParser jsonParser = jsonFactory.createJsonParser(json); return mapper.readValue(jsonParser, valueType); } catch (Exception e) { return null; } }
public static String serializeToJson(Object object) { try { StringWriter sw = new StringWriter(); // serialize ObjectMapper mapper = new ObjectMapper(); MappingJsonFactory jsonFactory = new MappingJsonFactory(); JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw); mapper.writeValue(jsonGenerator, object); sw.close(); return sw.toString(); } catch (Exception e) { return null; } }
/** * A writer object is created in AutobahnConnection. * * @param looper The message looper associated with the thread running this object. * @param master The message handler associated with the master thread (running AutobahnConnection). * @param socket The TCP socket (channel) the WebSocket connection runs over. * @param options WebSockets options for the underlying WebSockets connection. */ public WampWriter(Looper looper, Handler master, SocketChannel socket, WebSocketOptions options) { super(looper, master, socket, options); mJsonFactory = new MappingJsonFactory(); mPayload = new NoCopyByteArrayOutputStream(); if (DEBUG) Log.d(TAG, "created"); }
public Map<String, FilteredEventAttributes> read(final InputStream inputStream) throws IOException { final JsonFactory jf = new MappingJsonFactory(); jf.enable(JsonParser.Feature.ALLOW_COMMENTS); final ObjectMapper mapper = new ObjectMapper(jf); // Read simple whitelisted attributes and map them to the default whitelist format return mapFilteredAttributes(mapper.<Map<String, List<Object>>>readValue(inputStream, new TypeReference<Map<String, List<Object>>>() {})); }
public void toJSON(Writer writer, T value) throws IOException { MappingJsonFactory factory = new MappingJsonFactory(); JsonGenerator generator = factory.createJsonGenerator(writer); if (usePrettyPrinter) { generator.useDefaultPrettyPrinter(); } ObjectMapper objectMapper = new ObjectMapper(); objectMapper.writeValue(generator, value); }
MappingJsonFactory jsonFactory = new MappingJsonFactory(); JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(bodyStream); mapper.writeValue(jsonGenerator, comment);
jsonFactory = new MappingJsonFactory(objMapper); final long scanIntervalSecs = conf.getLong( TIMELINE_SERVICE_ENTITYFILE_SCAN_INTERVAL_SECONDS,
jsonFactory = new MappingJsonFactory(objMapper); final long scanIntervalSecs = conf.getLong( YarnConfiguration
JsonFactory f = new MappingJsonFactory(); JsonParser jp = f.createJsonParser(br); JsonToken current;
/** * * @param jf JsonFactory to use: if null, a new {@link MappingJsonFactory} will be constructed * @param sp SerializerProvider to use: if null, a {@link StdSerializerProvider} will be constructed * @param dp DeserializerProvider to use: if null, a {@link StdDeserializerProvider} will be constructed * @param sconfig Serialization configuration to use; if null, basic {@link SerializationConfig} * will be constructed * @param dconfig Deserialization configuration to use; if null, basic {@link DeserializationConfig} * will be constructed */ public ObjectMapper(JsonFactory jf, SerializerProvider sp, DeserializerProvider dp, SerializationConfig sconfig, DeserializationConfig dconfig) { /* 02-Mar-2009, tatu: Important: we MUST default to using * the mapping factory, otherwise tree serialization will * have problems with POJONodes. * 03-Jan-2010, tatu: and obviously we also must pass 'this', * to create actual linking. */ _jsonFactory = (jf == null) ? new MappingJsonFactory(this) : jf; _serializationConfig = (sconfig == null) ? new SerializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR) : sconfig; _deserializationConfig = (dconfig == null) ? new DeserializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR) : dconfig; _serializerProvider = (sp == null) ? new StdSerializerProvider() : sp; _deserializerProvider = (dp == null) ? new StdDeserializerProvider() : dp; // Default serializer factory is stateless, can just assign _serializerFactory = BeanSerializerFactory.instance; // and use standard JsonNodeFactory initially _nodeFactory = JsonNodeFactory.instance; }
_jsonFactory = (jf == null) ? new MappingJsonFactory(this) : jf;
_jsonFactory = (jf == null) ? new MappingJsonFactory(this) : jf;
JsonParser jp = new MappingJsonFactory().createJsonParser(in); configureJsonParser(jp);
try { ObjectMapper mapper = BoardParserService.getJsonMapper(); JsonParser jp = new MappingJsonFactory().createJsonParser(in); BoardParserService.configureJsonParser(jp);
_jsonFactory = new MappingJsonFactory(this); } else { _jsonFactory = jf;
/** * Creates a new {@link Json} instance. */ public Json() { this.factory = new MappingJsonFactory(); factory.enable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); factory.enable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); factory.enable(JsonGenerator.Feature.QUOTE_FIELD_NAMES); factory.enable(JsonParser.Feature.ALLOW_COMMENTS); factory.enable(JsonParser.Feature.AUTO_CLOSE_SOURCE); this.mapper = (ObjectMapper) factory.getCodec(); mapper.setPropertyNamingStrategy(AnnotationSensitivePropertyNamingStrategy.INSTANCE); mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.disable(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING); mapper.disable(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING); mapper.registerModule(new GuavaModule()); mapper.registerModule(new LogbackModule()); mapper.registerModule(new GuavaExtrasModule()); this.typeFactory = mapper.getTypeFactory(); }