• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #ifndef UPB_JSONENCODE_H_
3 #define UPB_JSONENCODE_H_
4 
5 #include "upb/def.h"
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 enum {
12   /* When set, emits 0/default values.  TODO(haberman): proto3 only? */
13   UPB_JSONENC_EMITDEFAULTS = 1,
14 
15   /* When set, use normal (snake_caes) field names instead of JSON (camelCase)
16      names. */
17   UPB_JSONENC_PROTONAMES = 2
18 };
19 
20 /* Encodes the given |msg| to JSON format.  The message's reflection is given in
21  * |m|.  The symtab in |symtab| is used to find extensions (if NULL, extensions
22  * will not be printed).
23  *
24  * Output is placed in the given buffer, and always NULL-terminated.  The output
25  * size (excluding NULL) is returned.  This means that a return value >= |size|
26  * implies that the output was truncated.  (These are the same semantics as
27  * snprintf()). */
28 size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
29                        const upb_symtab *ext_pool, int options, char *buf,
30                        size_t size, upb_status *status);
31 
32 #ifdef __cplusplus
33 }  /* extern "C" */
34 #endif
35 
36 #endif  /* UPB_JSONENCODE_H_ */
37