mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-02 06:06:59 -06:00
Core: ParseJSON(const char *) now returns ErrorValue if input is invalid
git-svn-id: svn://ultimatepp.org/upp/trunk@4144 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ba085d9583
commit
c45134d1f2
2 changed files with 11 additions and 5 deletions
|
|
@ -41,8 +41,13 @@ Value ParseJSON(CParser& p)
|
|||
|
||||
Value ParseJSON(const char *s)
|
||||
{
|
||||
CParser p(s);
|
||||
return ParseJSON(p);
|
||||
try {
|
||||
CParser p(s);
|
||||
return ParseJSON(p);
|
||||
}
|
||||
catch(CParser::Error) {
|
||||
return ErrorValue();
|
||||
}
|
||||
}
|
||||
|
||||
String AsJSON(const Value& v, const String& sep, bool pretty)
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@ topic "JSON support";
|
|||
]_[*@3 p])&]
|
||||
[s2;%% Parses JSON represented from [%-*@3 p]. It is possible to parse
|
||||
only part of whole text (e.g. when to parse just single element
|
||||
of array `- parser the stops at the end of element. Elements
|
||||
of array `- parser then stops at the end of element. Elements
|
||||
of JSON are parsed into corresponding Value types, JSON objects
|
||||
are represented by ValueMap, JSON arrays by ValueArray.&]
|
||||
are represented by ValueMap, JSON arrays by ValueArray. If input
|
||||
JSON is invalid throws CParser`::Error.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:ParseJSON`(const char`*`): [_^Value^ Value]_[* ParseJSON]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 s])&]
|
||||
[s2;%% Parses JSON text [%-*@3 s]. Elements of JSON are parsed into
|
||||
corresponding Value types, JSON objects are represented by ValueMap,
|
||||
JSON arrays by ValueArray.&]
|
||||
JSON arrays by ValueArray. If input JSON is invalid returns ErrorValue.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:AsJSON`(int`): [_^String^ String]_[* AsJSON]([@(0.0.255) int]_[*@3 i])&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue