public static void handle(JsonParser parser, JsonMessageHandler[] handlers) { parser.skipDelimiter('{'); string key; parser.readKeyFromJson(out key); if (key != "msgid") { throw new Exception(); // bad format } ulong msgID; parser.parseUnsignedInteger(out msgID); parser.skipSpacesEtc(); parser.skipDelimiter(','); parser.readKeyFromJson(out key); if (key != "msgbody") { throw new Exception(); // bad format } JsonMessageHandler handler = find_handler(msgID, handlers); if (handler != null) { handler._delegate(parser, msgID); //parser.skipDelimiter('}'); } else { throw new Exception(); } }
public static ulong parseMsgBegin(JsonParser parser) { parser.skipDelimiter('{'); string key; parser.readKeyFromJson(out key); if (key != "msgid") { throw new Exception(); // bad format } ulong msgID; parser.parseUnsignedInteger(out msgID); parser.skipSpacesEtc(); parser.skipDelimiter(','); parser.readKeyFromJson(out key); if (key != "msgbody") { throw new Exception(); // bad format } return(msgID); }
public static void parseMsgEnd(JsonParser parser) { parser.skipDelimiter('}'); }
public bool parseAddress(ref UInt64[] addr) { //mb: I am commneting out code paths I don't // know when can happend. Will uncomment as // I learn their reasons to exist. //if (p.isDelimiter('{')) //{ p.skipDelimiter('{'); if (p.isDelimiter('}')) { p.skipDelimiter('}'); //p.skipDelimiter(']'); //p.skipDelimiter('}'); return(false); } //} //else if (p.isDelimiter(']')) //{ // p.skipDelimiter(']'); // p.skipDelimiter('}'); // return false; //} parseKey("addr"); p.skipDelimiter('['); List <UInt64> tmpAddr = new List <ulong>(); if (!p.isDelimiter(']')) // there are some items there { UInt64 tmp; for (; ;) { p.parseUnsignedInteger(out tmp); tmpAddr.Add(tmp); if (p.isDelimiter(',')) { p.skipDelimiter(','); continue; } if (p.isDelimiter(']')) { p.skipDelimiter(']'); break; } } } else { p.skipDelimiter(']'); } //if (p.isDelimiter(',')) p.skipDelimiter(','); //else // throw new Exception(); // bad format addr = tmpAddr.ToArray(); return(true); }