|
|
@ -2,6 +2,7 @@ package com.jayway.jsonpath.internal; |
|
|
|
|
|
|
|
|
|
|
|
import com.jayway.jsonpath.Configuration; |
|
|
|
import com.jayway.jsonpath.Configuration; |
|
|
|
import com.jayway.jsonpath.InvalidModificationException; |
|
|
|
import com.jayway.jsonpath.InvalidModificationException; |
|
|
|
|
|
|
|
import com.jayway.jsonpath.InvalidPathException; |
|
|
|
import com.jayway.jsonpath.JsonPath; |
|
|
|
import com.jayway.jsonpath.JsonPath; |
|
|
|
import com.jayway.jsonpath.spi.json.JsonProvider; |
|
|
|
import com.jayway.jsonpath.spi.json.JsonProvider; |
|
|
|
|
|
|
|
|
|
|
@ -53,6 +54,9 @@ public abstract class PathRef implements Comparable<PathRef> { |
|
|
|
|
|
|
|
|
|
|
|
protected void renameInMap(Object targetMap, String oldKeyName, String newKeyName, Configuration configuration){ |
|
|
|
protected void renameInMap(Object targetMap, String oldKeyName, String newKeyName, Configuration configuration){ |
|
|
|
if(configuration.jsonProvider().isMap(targetMap)){ |
|
|
|
if(configuration.jsonProvider().isMap(targetMap)){ |
|
|
|
|
|
|
|
if(configuration.jsonProvider().getMapValue(targetMap, oldKeyName) == JsonProvider.UNDEFINED){ |
|
|
|
|
|
|
|
throw new InvalidPathException("Key "+oldKeyName+" not found in map!"); |
|
|
|
|
|
|
|
} |
|
|
|
configuration.jsonProvider().setProperty(targetMap, newKeyName, configuration.jsonProvider().getMapValue(targetMap, oldKeyName)); |
|
|
|
configuration.jsonProvider().setProperty(targetMap, newKeyName, configuration.jsonProvider().getMapValue(targetMap, oldKeyName)); |
|
|
|
configuration.jsonProvider().removeProperty(targetMap, oldKeyName); |
|
|
|
configuration.jsonProvider().removeProperty(targetMap, oldKeyName); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|