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

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

Go to download

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.

There is a newer version: 2.0.3
Show newest version
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