All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aerospike.documentapi.JsonPathQuery Maven / Gradle / Ivy

package com.aerospike.documentapi;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.jayway.jsonpath.JsonPath;

public class JsonPathQuery {

    public static Object read(JsonPathObject jsonPathObject, Object object) throws JsonProcessingException {
        String resultJson = JsonConverters.convertObjectToJsonString(object);
        String jsonPath = "$" + jsonPathObject.getJsonPathSecondStepQuery();
        return JsonPath.read(resultJson, jsonPath);
    }

    public static Object set(JsonPathObject jsonPathObject, Object object, Object value) throws JsonProcessingException {
        String resultJson = JsonConverters.convertObjectToJsonString(object);
        String jsonPath = "$" + jsonPathObject.getJsonPathSecondStepQuery();
        return JsonPath.parse(resultJson).set(jsonPath, value).json();
    }

    public static Object append(JsonPathObject jsonPathObject, Object object, Object value) throws JsonProcessingException {
        String resultJson = JsonConverters.convertObjectToJsonString(object);
        String jsonPath = "$" + jsonPathObject.getJsonPathSecondStepQuery();
        return JsonPath.parse(resultJson).add(jsonPath, value).json();
    }

    public static Object delete(JsonPathObject jsonPathObject, Object object) throws JsonProcessingException {
        String resultJson = JsonConverters.convertObjectToJsonString(object);
        String jsonPath = "$" + jsonPathObject.getJsonPathSecondStepQuery();
        return JsonPath.parse(resultJson).delete(jsonPath).json();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy