Emit upbdev JSON using numeric representation for enums.

PiperOrigin-RevId: 516273336
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent bdee30b0a6
commit b9fb58bba5
  1. 5
      upbc/upbdev.c

@ -59,13 +59,14 @@ static upb_StringView upbc_JsonEncode(const upbc_CodeGeneratorRequest* request,
upb_DefPool* s = upb_DefPool_New(); upb_DefPool* s = upb_DefPool_New();
const upb_MessageDef* m = upbc_CodeGeneratorRequest_getmsgdef(s); const upb_MessageDef* m = upbc_CodeGeneratorRequest_getmsgdef(s);
const int options = upb_JsonEncode_FormatEnumsAsIntegers;
out.size = upb_JsonEncode(request, m, s, 0, NULL, 0, status); out.size = upb_JsonEncode(request, m, s, options, NULL, 0, status);
if (!upb_Status_IsOk(status)) goto done; if (!upb_Status_IsOk(status)) goto done;
char* data = (char*)upb_Arena_Malloc(arena, out.size + 1); char* data = (char*)upb_Arena_Malloc(arena, out.size + 1);
(void)upb_JsonEncode(request, m, s, 0, data, out.size + 1, status); (void)upb_JsonEncode(request, m, s, options, data, out.size + 1, status);
if (!upb_Status_IsOk(status)) goto done; if (!upb_Status_IsOk(status)) goto done;
out.data = (const char*)data; out.data = (const char*)data;

Loading…
Cancel
Save