@Test public void test() throws MalformedURLException, URISyntaxException { JsonSelector selector = new JsonSelector(); byte[] data = "{\"category\": \"reference\"}".getBytes(); FetchMetadata fetchMetadata = new FetchMetadata().setUri(Uri.create("http: Instance<String> instance = selector.init(new BlobMetadata().setFetchMetadata(fetchMetadata), Payloads.newByteArrayPayload(data), false); List<String> results = instance.select("$.category", DataConverter.DEFAULT); Assertions.assertThat(results).containsExactly("reference"); }
@Override public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.ALWAYS_RETURN_LIST); } }); DocumentContext context; try { context = JsonPath.parse(payload.openStream()); } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new JsonSelectorInstance(context); }
JsonSelector extends BodySelector<String> { @Override public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.ALWAYS_RETURN_LIST); } }); DocumentContext context; try { context = JsonPath.parse(payload.openStream()); } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new JsonSelectorInstance(context); } }
JsonSelector extends BodySelector<String> { @Override public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.ALWAYS_RETURN_LIST); } }); DocumentContext context; try { context = JsonPath.parse(payload.openStream()); } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new JsonSelectorInstance(context); }  }
JsonSelector extends BodySelector<String> { @Override public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.ALWAYS_RETURN_LIST); } }); DocumentContext context; try { context = JsonPath.parse(payload.openStream()); } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new JsonSelectorInstance(context); }  @Override String name(); @Override Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment); }
JsonSelector extends BodySelector<String> { @Override public Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment) { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new JacksonJsonProvider(); private final MappingProvider mappingProvider = new JacksonMappingProvider(); @Override public JsonProvider jsonProvider() { return jsonProvider; } @Override public MappingProvider mappingProvider() { return mappingProvider; } @Override public Set<Option> options() { return EnumSet.of(Option.ALWAYS_RETURN_LIST); } }); DocumentContext context; try { context = JsonPath.parse(payload.openStream()); } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new JsonSelectorInstance(context); }  @Override String name(); @Override Instance<String> init(BlobMetadata data, Payload payload, boolean isSegment);  }