I have seen others with this same error, but it has been caused by something else so none of the responses have helped me. I have a class called Diff:
public class Diff {
private String path;
private String value;
private Operation operation;
public enum Operation {
ADD, REPLACE, REMOVE
}
//getters and setters
}
I need to apply this to a Json object. When working with this, I use the following command on a Diff:
mapper.valueToTree(diff);
This returns an ObjectNode containing:
{"path":"hello","value":"there","operation":"ADD"}
I want to turn this into a JsonPatch that will be applied to a JsonNode. To get the JsonPatch, I use the following:
JsonPatch jsonPatch = JsonPatch.fromJson(mapper.valueToTree(diff));
This, however, will throw the following exception:
Can not deserialize instance of java.util.ArrayList out of FIELD_NAME token
Any idea why this is happening? There isn't even an ArrayList involved (to my knowledge)