19 package org.turro.elephant.impl.util;
21 import com.jayway.jsonpath.DocumentContext;
22 import com.jayway.jsonpath.JsonPath;
24 import java.io.IOException;
25 import java.util.List;
27 import org.turro.reflection.ReflectionUtil;
35 private final File file;
36 private final String json;
48 public List
list(String path)
throws IOException {
49 return load().read(path, java.util.List.class);
52 public Map
map(String path)
throws IOException {
53 return load().read(path, java.util.Map.class);
56 public String
read(String path)
throws IOException {
57 return load().read(path);
60 public Object
read(String path, String javaClass)
throws IOException {
61 return load().read(path, ReflectionUtil.classCheck(javaClass));
64 public <T> T
read(String path, Class<T> javaClass)
throws IOException {
65 return load().read(path, javaClass);
68 public JsonReader put(String path, String key, Object value)
throws IOException {
69 load().put(path, key, value);
74 load().add(path, value);
80 private DocumentContext _parser;
82 private DocumentContext load() throws IOException {
85 _parser = JsonPath.parse(file);
87 _parser = JsonPath.parse(json);
JsonReader put(String path, String key, Object value)
Object read(String path, String javaClass)
JsonReader add(String path, Object value)