From 13c59cb051c4deee5367f9c5fc7b5d07363496a0 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 4 Dec 2018 15:21:32 -0800 Subject: Implement json decoding for Any message. (#130) * Implement json decoding for Any message. type url may not appear as the first value in json. As a result, other data cannot be resolved before resolving type url. To solve that, this change caches the start and end position of unparsed values and resolve them in end_any_object when type url has been resolved. * Handle Any in switch * Update json parser size * Fix comments * Sync upstream * Add dependency on upb_pb for upb_json * Debug failed test * Fix cmake * Update test generated files * Remove debug tests --- upb/json/parser.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'upb/json/parser.h') diff --git a/upb/json/parser.h b/upb/json/parser.h index 15beaeb..fb5fd2f 100644 --- a/upb/json/parser.h +++ b/upb/json/parser.h @@ -29,7 +29,7 @@ UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted, * constructed. This hint may be an overestimate for some build configurations. * But if the parser library is upgraded without recompiling the application, * it may be an underestimate. */ -#define UPB_JSON_PARSER_SIZE 4672 +#define UPB_JSON_PARSER_SIZE 5712 #ifdef __cplusplus @@ -38,6 +38,7 @@ UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted, class upb::json::Parser { public: static Parser* Create(Environment* env, const ParserMethod* method, + const SymbolTable* symtab, Sink* output, bool ignore_json_unknown); BytesSink* input(); @@ -72,6 +73,7 @@ UPB_BEGIN_EXTERN_C upb_json_parser* upb_json_parser_create(upb_env* e, const upb_json_parsermethod* m, + const upb_symtab* symtab, upb_sink* output, bool ignore_json_unknown); upb_bytessink *upb_json_parser_input(upb_json_parser *p); @@ -93,8 +95,10 @@ UPB_END_EXTERN_C namespace upb { namespace json { inline Parser* Parser::Create(Environment* env, const ParserMethod* method, + const SymbolTable* symtab, Sink* output, bool ignore_json_unknown) { - return upb_json_parser_create(env, method, output, ignore_json_unknown); + return upb_json_parser_create( + env, method, symtab, output, ignore_json_unknown); } inline BytesSink* Parser::input() { return upb_json_parser_input(this); -- cgit v1.2.3