public Result runBoon() { String result = null; String error = null; long time; Iterator<Object> query = null; long now = System.currentTimeMillis(); try { if (!optionAsValues) { throw new UnsupportedOperationException("Not supported!"); } io.gatling.jsonpath.JsonPath jsonPath = JsonPath$.MODULE$.compile(path).right().get(); JsonParser jsonParser = new JsonParserCharArray(); Object jsonModel = jsonParser.parse(json); query = jsonPath.query(jsonModel); } catch (Exception e) { error = getError(e); } finally { time = System.currentTimeMillis() - now; if (query != null) { List<Object> res = new ArrayList<Object>(); while (query.hasNext()) { res.add(query.next()); } ObjectMapper mapper = new ObjectMapperImpl(); result = mapper.toJson(res); } return new Result("boon", time, result, error); } }
@Override public void toJson(Object value, Writer writer) { this.objectMapper.toJson(value, writer); }
@Override public String toJson(Object value) throws Exception { return this.objectMapper.writeValueAsString(value); }
public ObjectMapperImpl () { this.parserFactory = new JsonParserFactory(); this.serializerFactory = new JsonSerializerFactory(); this.serializerFactory.useFieldsOnly(); }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T fromJson(Object json, Map<String, Object> javaTypes) throws Exception { JsonParserAndMapper parser = this.objectMapper.parser(); logger.warn("Boon doesn't support the Map 'key' conversion. Will be returned raw Map<String, Object>"); if (json instanceof String) { return (T) parser.parseMap((String) json); return (T) parser.parseMap((byte[]) json); return (T) parser.parseMap((char[]) json); return (T) parser.parseMap(new FileReader((File) json)); return (T) parser.parseMap((InputStream) json); return (T) parser.parseMap((Reader) json); return (T) this.objectMapper.readValue((String) json, (Class<Collection>) classType, contentClassType); return (T) this.objectMapper.readValue((byte[]) json, (Class<Collection>) classType, contentClassType); return (T) this.objectMapper.readValue((char[]) json, (Class<Collection>) classType, contentClassType); return (T) this.objectMapper.readValue((File) json, (Class<Collection>) classType, contentClassType); return (T) this.objectMapper.readValue((InputStream) json, (Class<Collection>) classType, contentClassType);
public BoonJsonObjectMapper(JsonParserFactory parserFactory, JsonSerializerFactory serializerFactory) { this.objectMapper = JsonFactory.create(parserFactory, serializerFactory); }
public JsonParserAndMapper create() { if ( charset == null ) { charset = StandardCharsets.UTF_8; } return new JsonMappingParser ( createMapper(), charset, lax, chop, lazyChop ); }
@Override public <T> T fromJson(Object json, Class<T> type) throws Exception { if (json instanceof String) { return this.objectMapper.readValue((String) json, type); } else if (json instanceof byte[]) { return this.objectMapper.readValue((byte[]) json, type); } else if (json instanceof char[]) { return this.objectMapper.readValue((char[]) json, type); } else if (json instanceof File) { return this.objectMapper.readValue((File) json, type); } else if (json instanceof InputStream) { return this.objectMapper.readValue((InputStream) json, type); } else if (json instanceof Reader) { return this.objectMapper.readValue((Reader) json, type); } else { throw new IllegalArgumentException("'json' argument must be an instance of: " + supportedJsonTypes + " , but gotten: " + json.getClass()); } }
@Override @SuppressWarnings("unchecked") public Map<String, Object> toJsonNode(final Object value) throws Exception { PipedReader in = new PipedReader(); final PipedWriter out = new PipedWriter(in); Executors.newSingleThreadExecutor().execute(() -> toJson(value, out)); return (Map<String, Object>) this.slurper.parse(in); }
public ObjectMapperImpl () { this.parserFactory = new JsonParserFactory(); this.serializerFactory = new JsonSerializerFactory(); this.serializerFactory.useFieldsOnly(); }
public BoonJsonObjectMapper() { this.objectMapper = JsonFactory.create(); }
public JsonParserAndMapper create() { if ( charset == null ) { charset = StandardCharsets.UTF_8; } return new JsonMappingParser ( createMapper(), charset, lax, chop, lazyChop ); }
public ObjectMapperImpl () { this.parserFactory = new JsonParserFactory(); this.serializerFactory = new JsonSerializerFactory(); this.serializerFactory.useFieldsOnly(); }
public JsonParserAndMapper create() { if ( charset == null ) { charset = StandardCharsets.UTF_8; } return new JsonMappingParser ( createMapper(), charset, lax, chop, lazyChop ); }