I'm creating a drawing application in Swift that can be redrawn on canvas for HTML. Just a prototype. What I need is to get this data in JSON
format to my database.
I organized everything in arrays and dictionaries.
How can I generate something like this:
{
"data": [
{
"width": 150,
"height": 200,
"x": 45,
"y": 65,
"id": "line4"
},
{
"width": 150,
"height": 200,
"x": 45,
"y": 65,
"id": "Shape1"
},
{
"width": 150,
"height": 200,
"x": 45,
"y": 65,
"id": "line3"
},
{
"width": 350,
"height": 400,
"x": 45,
"y": 65,
"id": "line2"
}
]
}
Using Arrays and Dicionaries (and / or Structs
) and then turn into Json.
I tried to create a one Dictionary within an array within another Dictionary. The data is dynamic, that is the big problem.
help will be appreciated