I have a JsonNode with this JSON in it:
{"temperature":17,"long":200,"lat":100}
I want to change JsonNode to look like this
{"MyNewFieldName":17,"long":200,"lat":100}
Is it possible to use the Jackson API?
You cannot rename keys into JSON pairs with the key. You will need to create a new key-value pair with the same value, but with a different key and delete the old one.
JsonNode node = ...; ObjectNode object = (ObjectNode) node; object.set("MyNewFieldName", new TextNode(node.get("temperature").asText())); object.remove("temperature");
Source: https://habr.com/ru/post/1544061/More articles:Class properties without superclass properties - pythonJavaFx 8: moving a component between parents while in place - javafxHow to prevent Wordpress from deleting HTML tags in excerpt - functionRails parameters are not passed to the 'params' variable - ruby-on-railsКак я могу просматривать задачи Android build Gradle из Android Studio? - androidПоказатель Matplotlib не отвечает при использовании с многопроцессорной обработкой - pythonComputing multiple aggregates using lapply (.SD, ...) in data.table R package - rGet the "absolute" state URL in Angular-UI? - angularjsBaby items let you drag and drop - javascriptRackspace/Vagrant: Работает с брандмауэром box - vagrantAll Articles