I am new to json and confuse how to do this. I have this basic info below i need to convert
"trailer":
"window":"broken"
"sidesteps":"dent"
"tractor":
"window":"craked"
"sidesteps":"missing"
"tire":
"tire1":
"pressure":"120"
"rim":"good"
"tire2":
"pressure":"120"
"rim":"good"
Create a dictionary from all the values you fetched from textFields. It will look like this,
Output:
You can use
NSMutableDictionaryto create a similar structure dynamically. You can create multiple mutable dictionaries and add it as an object of another dictionary to achieve the above result.To convert to JSON data you can do this,
If you want to convert to a string to view the data,
If you want to set this postbody to http request and pass it to server, you can set it as,