com.aerospike.documentapi.JsonPathQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-document-api Show documentation
Show all versions of aerospike-document-api Show documentation
This project provides an API which allows Aerospike CDT (Collection Data Type) objects to be accessed and mutated using JSON like syntax.
Effectively this provides what can be termed a document API as CDT objects can be used to represent JSON in the Aerospike database.
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 - 2024 Weber Informatics LLC | Privacy Policy