|
|
@ -1,9 +1,6 @@ |
|
|
|
package com.jayway.jsonpath.internal; |
|
|
|
package com.jayway.jsonpath.internal; |
|
|
|
|
|
|
|
|
|
|
|
import com.jayway.jsonpath.Configuration; |
|
|
|
import com.jayway.jsonpath.*; |
|
|
|
import com.jayway.jsonpath.InvalidModificationException; |
|
|
|
|
|
|
|
import com.jayway.jsonpath.InvalidPathException; |
|
|
|
|
|
|
|
import com.jayway.jsonpath.JsonPath; |
|
|
|
|
|
|
|
import com.jayway.jsonpath.spi.json.JsonProvider; |
|
|
|
import com.jayway.jsonpath.spi.json.JsonProvider; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
@ -55,7 +52,7 @@ 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){ |
|
|
|
if(configuration.jsonProvider().getMapValue(targetMap, oldKeyName) == JsonProvider.UNDEFINED){ |
|
|
|
throw new InvalidPathException("Key "+oldKeyName+" not found in map!"); |
|
|
|
throw new PathNotFoundException("No results for Key "+oldKeyName+" 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); |
|
|
|