I would like to read in the string {"a": 1.0}
as a generic Java Object while keeping the same string format. However, when I try, Jackson automatically changes the internal representation to {a = 1}
. In other words, how can I get the following code to print {"a": 1.0}
instead of {a = 1}
? Note that, I have to read it in as an Object
(due to other program constraints).
import org.codehaus.jackson.map.ObjectMapper;
public class Main {
public static void main(String[] args) {
try
{
ObjectMapper mapper = new ObjectMapper();
Object myObject = mapper.readValue("{\"a\": 1.0}", Object.class);
System.out.println(myObject.toString());
}
catch (Exception e)
{
e.printStackTrace();
System.err.println(e.getMessage());
}
}
}