Evaluate JsonPath expression using given read context and return result as object.
@param readerContext
@param jsonPathExpression
@return
515824
public static Object evaluate(ReadContext readerContext, String jsonPathExpression) {
        String expression = jsonPathExpression;
        String jsonPathFunction = null;
        for (String name : JsonPathFunctions.getSupportedFunctions()) {
            if (expression.endsWith(String.format(".%s()", name))) {
                jsonPathFunction = name;
                expression = expression.substring(0, expression.length() - String.format(".%s()", name).length());
            }
        }

        Object jsonPathResult = null;
        PathNotFoundException pathNotFoundException = null;
        try {
            if (JsonPath.isPathDefinite(expression)) {
                jsonPathResult = readerContext.read(expression);
            } else {
                JSONArray values = readerContext.read(expression);
                if (values.size() == 1) {
                    jsonPathResult = values.get(0);
                } else {
                    jsonPathResult = values;
                }
            }
        } catch (PathNotFoundException e) {
            pathNotFoundException = e;
        }

        if (StringUtils.hasText(jsonPathFunction)) {
            jsonPathResult = JsonPathFunctions.evaluate(jsonPathResult, jsonPathFunction);
        }

        if (jsonPathResult == null && pathNotFoundException != null) {
            throw new CitrusRuntimeException(String.format("Failed to evaluate JSON path expression: %s", jsonPathExpression), pathNotFoundException);
        }

        return jsonPathResult;
    }
583942
public static Object parse(Reader reader, JSONVisitor handler)
            throws IOException, ParseException {
        return parse(reader, handler, JSONToken.ANY);
    }
127885
public static Value parse(Reader reader) throws JSONException {
		try {
			return new Parser(reader).parse();
		}
		finally {
			try {
				reader.close();
			}
			catch (IOException e) {
			}
		}
	}
1273217
@Override
	public Result<Response> handleAsync(JsonPath jsonPath, QueryAdapter queryAdapter, Document requestBody) {
		Serializable id = jsonPath.getId();

		RegistryEntry rootEntry = jsonPath.getRootEntry();
		ResourceRepositoryAdapter resourceRepository = rootEntry.getResourceRepository();

		DocumentMappingConfig docummentMapperConfig = DocumentMappingConfig.create();
		DocumentMapper documentMapper = context.getDocumentMapper();

		return resourceRepository.findOne(id, queryAdapter)
				.merge(it -> documentMapper.toDocument(it, queryAdapter, docummentMapperConfig))
				.map(this::toResponse);
	}
1265468
public Object getJsonPath(String json, String jsonPath) {
        if (!JsonPath.isPathDefinite(jsonPath)) {
            throw new RuntimeException(jsonPath + " returns a list of results, not a single.");
        }
        return parseJson(json).read(jsonPath);
    }
613373
public JsonReader createReader(Reader reader) {
        return new JsonReader(reader, jsonObjectFactory, jsonArrayFactory, objectMapper, typeAdapters);
    }
246218
public static DocumentContext parse(File json, Configuration configuration) throws IOException {
        return new ParseContextImpl(configuration).parse(json);
    }
489472
public static JsonNode readJson(Reader source, ClassLoader classLoader) {
        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        try {
            if (source == null) {
                return NullNode.instance;
            }
            ObjectMapper mapper = poolMapper.borrowObject();
            if (mapper != null) {
                try {
                    return mapper.readTree(source);
                } finally {
                    poolMapper.returnObject(mapper);
                }
            }
            throw new SerializationException("No ObjectMapper instance avaialble!");
        } catch (Exception e) {
            throw e instanceof SerializationException ? (SerializationException) e
                    : new SerializationException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    }
454956
private void expressionsApiUsage() throws JsonProcessingException, ApiException {
        
        LOG.info("The Expressions API usage.");
        Expressions api = retinaApisInstance.expressionsApi();
        ExpressionsApi expressionsApi = new ExpressionsApi(API_KEY);
        expressionsApi.setBasePath("http://api.cortical.io/rest");
        
        /**
         * 
         */
        LOG.info("Expressions API: getContextsForExpression");
        List<List<Context>> bulkContexts = api.getContextsBulk(TERM_1, TERM_2, TERM_2);
        logBulkContexts(bulkContexts);
        
        bulkContexts = api.getContextsBulk(true, TERM_1, or(TERM_2, TEXT_2).add(TERM_1), TEXT_1);
        logBulkContexts(bulkContexts);
        
        bulkContexts = api.getContextsBulk(1.0, TERM_1, TERM_2, or(TERM_2, TEXT_2).add(TERM_1));
        logBulkContexts(bulkContexts);
        
        bulkContexts = api.getContextsBulk(true, 1.0, TERM_1, or(TERM_2, TEXT_2).add(TERM_1), TEXT_1);
        logBulkContexts(bulkContexts);
        
        bulkContexts = api.getContextsBulk(new Pagination(0, 2), true, 1.0, TERM_1, TERM_2, or(TERM_2, TEXT_2));
        logBulkContexts(bulkContexts);
        /**
         * 
         */
        LOG.info("Expressions API: getContextsForExpression");
        List<Context> contexts = api.getContexts(TERM_1);
        logContext(contexts);
        
        contexts = api.getContexts(or(TERM_2, TEXT_2));
        logContext(contexts);
        
        contexts = api.getContexts(true, or(TERM_2, TEXT_2));
        logContext(contexts);
        
        contexts = api.getContexts(0.1, sub(TERM_2, TERM_1));
        logContext(contexts);
        
        contexts = api.getContexts(true, 1.0, and(TERM_2, TERM_1));
        logContext(contexts);
        
        contexts = api.getContexts(new Pagination(0, 2), true, 1.0, xor(TERM_2, TERM_1));
        logContext(contexts);
        /**
         * 
         */
        LOG.info("Expressions API: getSimilarTermsForBulkExpressionContext");
        List<List<Term>> bulkTerms =
                api.getSimilarTermsBulk(null, PosType.ADJECTIVE, TERM_1, and(TERM_2, TEXT_2), TEXT_1);
        logBulkTerms(bulkTerms);
        
        bulkTerms = api.getSimilarTermsBulk(1, PosType.ADJECTIVE, true, TERM_1, TERM_2, TEXT_1);
        logBulkTerms(bulkTerms);
        
        bulkTerms = api.getSimilarTermsBulk(1, PosType.ADJECTIVE, 1.0, TERM_1, and(TERM_2, TEXT_2).add(TERM_1), TEXT_1);
        logBulkTerms(bulkTerms);
        
        bulkTerms =
                api.getSimilarTermsBulk(1, PosType.ADJECTIVE, true, 1.0, TERM_1, and(TERM_2, TEXT_2).add(TERM_1),
                        TEXT_1);
        logBulkTerms(bulkTerms);
        
        bulkTerms =
                api.getSimilarTermsBulk(1, PosType.ADJECTIVE, new Pagination(1, 2), true, 1.0, TERM_1, TERM_2, TEXT_1);
        logBulkTerms(bulkTerms);
        /**
         * 
         */
        LOG.info("Expressions API: resolveExpression");
        Fingerprint fingerprint = api.resolve(TERM_1);
        logFingerprint(fingerprint);
        
        fingerprint = api.resolve(1.0, and(TERM_1, TEXT_1));
        logFingerprint(fingerprint);
        
        /**
         * 
         */
        LOG.info("Expressions API: getSimilarTermsForExpressionContext");
        List<Term> terms = api.getSimilarTerms(null, null, TEXT_1);
        logTerms(terms);
        
        terms = api.getSimilarTerms(TEXT_2);
        logTerms(terms);
        
        String bodyText = "{ \"text\": \"the first text to use\"}";
        List<Term> similarterms =
                expressionsApi.getSimilarTermsForExpressionContext(bodyText, null, null, false, "en_associative", null,
                        null, null);
        logTerms(similarterms);
        
        terms = api.getSimilarTerms(null, PosType.NOUN, and(TERM_2, TEXT_2).add(TERM_1));
        logTerms(terms);
        
    }
800035
public static JsonNode getValue(JsonNode node, String dPath) {
        String[] paths = splitDpath(dPath);
        Object result = node;
        for (String path : paths) {
            result = extractValue(result, path);
        }
        if (result instanceof POJONode) {
            result = extractValue((POJONode) result);
        }
        return result != null
                ? result instanceof JsonNode ? ((JsonNode) result) : JacksonUtils.toJson(result)
                : null;
    }
537164
@Override
    public List<String> setTargetHostsFromJsonPath(String jsonPath,
            String sourcePath, HostsSourceType sourceType)
            throws TargetHostsLoadException {

        List<String> targetHosts = new ArrayList<String>();
        try {
            String content = getContentFromPath(sourcePath, sourceType);
            targetHosts = JsonPath.read(content, jsonPath);

        } catch (IOException e) {
            throw new TargetHostsLoadException("IEException when reading  "
                    + sourcePath, e);
        }

        return targetHosts;
    }
429395
private void traverseJsonData(JSONObject jsonData, String jsonPath, TestContext context) {
        for (Iterator it = jsonData.entrySet().iterator(); it.hasNext();) {
            Map.Entry jsonEntry = (Map.Entry) it.next();

            if (jsonEntry.getValue() instanceof JSONObject) {
                traverseJsonData((JSONObject) jsonEntry.getValue(), (StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()), context);
            } else if (jsonEntry.getValue() instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) jsonEntry.getValue();
                for (int i = 0; i < jsonArray.size(); i++) {
                    if (jsonArray.get(i) instanceof JSONObject) {
                        traverseJsonData((JSONObject) jsonArray.get(i), String.format((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()) + "[%s]", i), context);
                    } else {
                        jsonArray.set(i, translate(String.format((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()) + "[%s]", i), jsonArray.get(i), context));
                    }
                }
            } else {
                jsonEntry.setValue(translate((StringUtils.hasText(jsonPath) ? jsonPath + "." + jsonEntry.getKey() : jsonEntry.getKey().toString()),
                        jsonEntry.getValue() != null ? jsonEntry.getValue() : null, context));
            }
        }
    }
638130
@Override
	protected Reader generateResource(String path, GeneratorContext context) {

		Reader rd = null;

		try {
			List<Class<?>> excluded = new ArrayList<>();
			excluded.add(ISassResourceGenerator.class);
			JoinableResourceBundle bundle = context.getBundle();
			rd = context.getResourceReaderHandler().getResource(bundle, path, false, excluded);

			if (rd == null) {
				throw new ResourceNotFoundException(path);
			}
			String content = IOUtils.toString(rd);

			String result = compile(bundle, content, path, context);
			rd = new StringReader(result);

		} catch (ResourceNotFoundException | IOException e) {
			throw new BundlingProcessException("Unable to generate content for resource path : '" + path + "'", e);
		}

		return rd;
	}
252538
public void parseJSON(Reader reader) {
        Listener sajListener = new Listener();
        new JSONAnnie(reader).parse(sajListener);
    }
1174351
private JsonPathMessageValidationContext getJsonPathValidationContext() {
        if (jsonPathValidationContext == null) {
            jsonPathValidationContext = new JsonPathMessageValidationContext();

            getAction().getValidationContexts().add(jsonPathValidationContext);
        }

        return jsonPathValidationContext;
    }
84402
public static JsonAsserter with(Reader reader) throws IOException {
        return new JsonAsserterImpl(JsonPath.parse(convertReaderToString(reader)).json());

    }
1189812
public Iterator<Object> iterator(InputStream inputStream, JsonPath jsonPath) {
        SurfingContext context = createIteratorContext(jsonPath);
        final ResumableParser resumableParser = jsonParserAdapter.createResumableParser(inputStream, context);
        resumableParser.parse();
        return createIterator(context, resumableParser);
    }