diff --git a/Message/Json.cpp b/Message/Json.cpp index 9a933a6e..34554dd8 100644 --- a/Message/Json.cpp +++ b/Message/Json.cpp @@ -1,5 +1,9 @@ #include "Json.h" +static bool isSpace(char ch); +static cstring SkipSpace(cstring str, int& len); +static int find(cstring str, int len, char ch); + static const Json Null; Json::Json() { Init(nullptr, 0); } @@ -11,8 +15,10 @@ Json::Json(cstring str) void Json::Init(cstring str, int len) { - _str = str; + //_str = str; _len = len; + + _str = SkipSpace(str, _len); } // 值类型 @@ -116,100 +122,6 @@ double Json::AsDouble() const return s.ToDouble(); } -bool isSpace(char ch) -{ - return ch == ' ' || - ch == '\t' || - ch == '\r' || - ch == '\n'; - -} - -// 跳过空格 -cstring SkipSpace(cstring str) -{ - while(isSpace(str[0])) str++; - - return str; -} - -// 读取对象结尾 -int readObject(cstring str, int len) -{ - // { ... } - if(str[0] != '{') return 0; - - // 记录括号配对 - int m = 0; - // 是否在字符串中,此时不算括号 - bool s = false; - for(int i=0; i