1

for example I have a List<Point> vertices which has 3 points and each of them have x and y would look in JSON notation?

for example List vertices:

[0] -> x = 1 , y = 2
[1] -> x = 4, y = 5
[2] -> x = 7, y = 5

Considering that object Color has two parameters and in JSON it looks like

"colour":{"value":-16711936,"falpha":0.0}...

So it should look like

"[0]":{"x": 1, "y":2}...

And so on. But i need to put it in the List vertices in JSON.

2
  • 3
    I dont get it, you want to serialize a Map of points, Colors?? Commented Mar 18, 2016 at 15:51
  • {"listOfShapeEvents":[{"xStart":20,"yStart":40,"xEnd":30,"yEnd":90,"colour":{"value":-65536,"falpha":0.0},"thickness":5,"shapeType":"LINE","eventType":"SHAPE"}]} I have this this is my straight Line, which reading just an objects from Java. But i need to read a list named "vertices" which has 3 points and each point has 2 parameters x and y . How is going to look in JSON notation Commented Mar 18, 2016 at 15:54

2 Answers 2

2

This conversion problem has been solved with multiple java libraries. Jackson is a good library for Java to / from JSON

http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/

Sign up to request clarification or add additional context in comments.

1 Comment

SO answers are not for recommending libraries.
0

The JSON for your described array of points would like this:

[
  {
    "x" : 1,
    "y" : 2
  },
  {
    "x" : 4,
    "y" : 5
  },
  {
    "x" : 7,
    "y" : 5
  }
]

Note the use of square brackets to indicate this is an array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.