Int main ()
{
/*
Array creation and analysis:
Example 1:
String strvalue = "{\" LDH \ ": \" 001 \ ", \" GFC \ ": \" 002 \ ", \" yyj \": \ "003 \", \ "Andy \": [\ "005 \", \ "123 \", \ "True \"]} ";
JSON: reader read;
JSON: Value value;
Value ["LDH"] = "001 ";
Value ["GFC"] = "002 ";
Value ["Andy"]. append ("005 ");
Value ["Andy"]. append ("123 ");
Value ["Andy"]. append ("true ");
// If (read. parse (strvalue, value ))
{
JSON: Value val_array = value ["Andy"];
Int isize = val_array.size ();
For (INT nindex = 0; nindex <isize; ++ nindex)
{
Cout <val_array [nindex] <Endl;
}
}
*/
/*
Example 2:
JSON: reader read;
JSON: Value value;
Value ["LDH"] = "001 ";
Value ["GFC"] = "002 ";
Value item;
Value array;
Item ["andy1"] = "005 ";
Array. append (item );
Item ["andy1"] = "123 ";
Array. append (item );
Item ["andy1"] = "true ";
Array. append (item );
Value ["Andy"] = array;
Cout <value. tostyledstring () <Endl;
JSON: Value val_array = value ["Andy"];
Int isize = val_array.size ();
For (INT nindex = 0; nindex <isize; ++ nindex)
{
Cout <val_array [nindex] <Endl;
If (! Val_array [nindex] ["andy1"]. isnull ())
{
Cout <val_array [nindex] ["andy1"] <Endl;
}
}
*/
/*
Example 3:
STD: String strvalue = "{\" Name \ ": \" JSON \ ", \" array \ ": [{\" CPP \": \ "jsoncpp \" },{ \ "Java \": \ "jsoninjava \" },{ \ "php \": \ "support \"}]} ";
JSON: Value value;
Reader read;
If (! Read. parse (strvalue, value ))
{
Return-1;
}
Cout <value. tostyledstring () <Endl;
JSON: Value val_array = value ["array"];
Int isize = val_array.size ();
For (INT nindex = 0; nindex <isize; ++ nindex)
{
Cout <val_array [nindex] <Endl;
If (val_array [nindex]. ismember ("CPP "))
{
Cout <val_array [nindex] ["CPP"] <Endl;
}
}
*/
Getchar ();
Return 0;
}
It was awkward to use jsoncpp at first. For example, there are three arrays in the third example, but val_array [nindex] cannot be used directly. asstring. the format is indeed not clear.
To sum up, no matter which form of array, you can directly look at the content of its corresponding index during parsing, and then we can export its resolution method.