cocos2dx json解析
#ifndef SPINE_JSON_H_
#define SPINE_JSON_H_
namespace cocos2d {
namespace extension {
/* Json Types: */
#define Json_False 0
#define Json_True 1
#define Json_NULL 2
#define Json_Number 3
#define Json_String 4
#define Json_Array 5
#define Json_Object 6
//json 结构体
typedef structJson {
struct Json* next;
struct Json* prev;//next/prev allow you to walk array/object chains(链条). Alternatively(或者), use getSize/getItemAt/getItem
struct Json* child; //An array or object item will have a child pointer pointing to a chain of the items in the array/object.
int type;//The type of the item, as above.
const char* valuestring;//The item's string, if type==Json_String
int valueint;//The item's number, if type==Json_Number
float valuefloat;//The item's number, if type==Json_Number
const char* name;//The item's name string, if this item is the child of, or is in the list of subitems of an object.
}Json;
//Supply(供给) a block(块) of JSON, and this returns a Json object you can interrogate(询问). Call Json_dispose when finished.
Json*Json_create (const char* value);
//Delete a Json entity and all subentities.
voidJson_dispose (Json* json);
//Returns the number of items in an array (or object).
intJson_getSize (Json* json);
// Retrieve(检索) item number "item" from array "array". Returns NULL if unsuccessful.
Json*Json_getItemAt (Json* json, int item);
//Get item "string" from object. Case insensitive.
Json*Json_getItem (Json* json, const char* string);
const char*Json_getString (Json* json, const char* name, const char* defaultValue);
floatJson_getFloat (Json* json, const char* name, float defaultValue);
intJson_getInt (Json* json, const char* name, int defaultValue);
//For analysing(分析) failed parses(解析). This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when Json_create() returns 0. 0 when Json_create() succeeds.
const char* Json_getError (void);
}} // namespace cocos2d { namespace extension {
#endif /* SPINE_JSON_H_ */