reference: JSON: try / catch for partial parsing

git-svn-id: svn://ultimatepp.org/upp/trunk@4145 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-11-07 14:08:47 +00:00
parent 5a4547708d
commit 172f6a9d0d

View file

@ -24,13 +24,18 @@ CONSOLE_APP_MAIN
String s = AsJSON(va);
DUMP(s);
CParser p2(s);
p2.PassChar('[');
if(!p2.Char(']')) {
do {
DUMP(ParseJSON(p2)["firstName"]);
try {
p2.PassChar('[');
if(!p2.Char(']')) {
do {
DUMP(ParseJSON(p2)["firstName"]);
}
while(p2.Char(','));
p2.PassChar(']');
}
while(p2.Char(','));
p2.PassChar(']');
}
catch(CParser::Error) {
LOG("invalid JSON");
}
LOG("- Composing JSON using support classes");