-
Notifications
You must be signed in to change notification settings - Fork 2
FAQ
Yes. See the simple example.
Yes. The parse()
entry point accepts a Map
. The following code will print out {"name":"tap"}
:
Map<String, Object> incoming = new HashMap<>();
incoming.put("name", "tap");
incoming.put("quantity", 10);
System.out.println(Tranquil.parse(incoming).read("name", "quantity=10"));
No (or maybe: not yet). Tranquil has an experimental feature which will accept XML and attempts to apply projections and predicates to it but it is not ready for use yet. If you are interested, watch (or contribute) to this issue.
Yes. See the nested example.
Yes. See the bespoke output types example.
Yes. Tranquil can be configured with an instance of the underlying Jackson or Gson library which pretty prints JSON output.
For example:
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
Tranquil.using(new JacksonMappingProvider(objectMapper))
.parse(json)
.read(select, where)
Gson gson = new GsonBuilder().setPrettyPrinting().create();
Tranquil.using(new GsonMappingProvider(gson))
.parse(json)
.read(select, where)
Yes. The exists()
entry point just applies the given predicates. No projections are involved and the return type is a boolean.
See the matching example.
Yes. Use the select()
entry point. For example: Tranquil.parse(json).select("name")
will return a JSON document containing only the name attribute from the incoming JSON.
Yes. Use the where()
entry point. For example: Tranquil.parse(json).where("name = 'tap'")
will return the entire incoming JSON as long as it contains an attribute name
with the value "tap"
.