0
votes

I am developing a simple project in Java to output a JSON file. The JSON file will include geo-location data which will have to be printed in this exact format:

 "location" : {
        "coordinates" : [ 
            -1.072925602, 
            51.27924757
        ],
        "type" : "Point"

Meaning each file will have two key fields coordinates and type, where coordinates will have the latitude and longitude data.

Now I am developing this using the standard JsonObjectBuilder and I really cannot find a way how to print the latitude and longitude data in that exact format; btw I cannot print it as a string.

Is there a way how to print an array of type double using the JsonObjectBuilder?

Thanks a lot guys

1

1 Answers

0
votes

Just print is as string and in the future, when you will need, you can always parse that string to double like that:

double x = Double.parseDouble(string);

where "string" is longitude (or latitude) as string