JSON is simply called objects and arrays in JavaScript, so these two structures are objects and arrays of two structures that can represent a variety of complex structures. 1. Object: The object in JS is represented as "{}" in the content, the data structure is {Key:value,key:value,...} The structure of key-value pairs, in object-oriented languages, key is the property of the object, value is the corresponding property value, so it is easy to understand that the value method is the object. Key Gets the property value, the type of the property value can be a number, a string, an array, several objects. 2, array: The array in JS is the middle bracket "[]" in the content, data structure for ["Java", "JavaScript", "VB",...], the value way and all languages, using index get, the type of field value can be number, string, array, object several. Through the object, the array 2 kinds of structure can be combined into a complex data structure. The following method converts an array and a dictionary to a JSON string, but the NSString object is not jsonobject, so an error occurs when the object is passed in NSString.
Invalid top-level type in JSON write
NSData *jsondata = [nsjsonserialization datawithjsonobject:connectordict options:0 Error:nil];
NSString *jsonstring1 = [[NSString alloc] Initwithdata:jsondata encoding:nsutf8stringencoding];
Array, dictionary to JSON string, string not supported