Search in sources :

Example 6 with EvaluationContext

use of com.jayway.jsonpath.internal.EvaluationContext in project JsonPath by jayway.

the class JsonPath method renameKey.

public <T> T renameKey(Object jsonObject, String oldKeyName, String newKeyName, Configuration configuration) {
    notNull(jsonObject, "json can not be null");
    notEmpty(newKeyName, "newKeyName can not be null or empty");
    notNull(configuration, "configuration can not be null");
    EvaluationContext evaluationContext = path.evaluate(jsonObject, jsonObject, configuration, true);
    for (PathRef updateOperation : evaluationContext.updateOperations()) {
        updateOperation.renameKey(oldKeyName, newKeyName, configuration);
    }
    return resultByConfiguration(jsonObject, configuration, evaluationContext);
}
Also used : PathRef(com.jayway.jsonpath.internal.PathRef) EvaluationContext(com.jayway.jsonpath.internal.EvaluationContext)

Aggregations

EvaluationContext (com.jayway.jsonpath.internal.EvaluationContext)6 PathRef (com.jayway.jsonpath.internal.PathRef)6