@@ -76,9 +76,7 @@ JSONB_API void jsonb_init(jsonb *builder);
76
76
* @param bufsize the JSON buffer size
77
77
* @return @ref jsonbcode value
78
78
*/
79
- JSONB_API jsonbcode jsonb_push_object (jsonb * builder ,
80
- char buf [],
81
- size_t bufsize );
79
+ JSONB_API jsonbcode jsonb_object (jsonb * builder , char buf [], size_t bufsize );
82
80
83
81
/**
84
82
* @brief Pop an object from the builder
@@ -88,7 +86,7 @@ JSONB_API jsonbcode jsonb_push_object(jsonb *builder,
88
86
* @param bufsize the JSON buffer size
89
87
* @return @ref jsonbcode value
90
88
*/
91
- JSONB_API jsonbcode jsonb_pop_object (jsonb * builder ,
89
+ JSONB_API jsonbcode jsonb_object_pop (jsonb * builder ,
92
90
char buf [],
93
91
size_t bufsize );
94
92
@@ -102,7 +100,7 @@ JSONB_API jsonbcode jsonb_pop_object(jsonb *builder,
102
100
* @param len the key length
103
101
* @return @ref jsonbcode value
104
102
*/
105
- JSONB_API jsonbcode jsonb_push_key (
103
+ JSONB_API jsonbcode jsonb_key (
106
104
jsonb * builder , char buf [], size_t bufsize , const char key [], size_t len );
107
105
108
106
/**
@@ -113,9 +111,7 @@ JSONB_API jsonbcode jsonb_push_key(
113
111
* @param bufsize the JSON buffer size
114
112
* @return @ref jsonbcode value
115
113
*/
116
- JSONB_API jsonbcode jsonb_push_array (jsonb * builder ,
117
- char buf [],
118
- size_t bufsize );
114
+ JSONB_API jsonbcode jsonb_array (jsonb * builder , char buf [], size_t bufsize );
119
115
120
116
/**
121
117
* @brief Pop an array from the builder
@@ -125,7 +121,7 @@ JSONB_API jsonbcode jsonb_push_array(jsonb *builder,
125
121
* @param bufsize the JSON buffer size
126
122
* @return @ref jsonbcode value
127
123
*/
128
- JSONB_API jsonbcode jsonb_pop_array (jsonb * builder ,
124
+ JSONB_API jsonbcode jsonb_array_pop (jsonb * builder ,
129
125
char buf [],
130
126
size_t bufsize );
131
127
@@ -139,11 +135,11 @@ JSONB_API jsonbcode jsonb_pop_array(jsonb *builder,
139
135
* @param len the token length
140
136
* @return @ref jsonbcode value
141
137
*/
142
- JSONB_API jsonbcode jsonb_push_token (jsonb * builder ,
143
- char buf [],
144
- size_t bufsize ,
145
- const char token [],
146
- size_t len );
138
+ JSONB_API jsonbcode jsonb_token (jsonb * builder ,
139
+ char buf [],
140
+ size_t bufsize ,
141
+ const char token [],
142
+ size_t len );
147
143
148
144
/**
149
145
* @brief Push a boolean token to the builder
@@ -154,10 +150,10 @@ JSONB_API jsonbcode jsonb_push_token(jsonb *builder,
154
150
* @param boolean the boolean to be inserted
155
151
* @return @ref jsonbcode value
156
152
*/
157
- JSONB_API jsonbcode jsonb_push_bool (jsonb * builder ,
158
- char buf [],
159
- size_t bufsize ,
160
- int boolean );
153
+ JSONB_API jsonbcode jsonb_bool (jsonb * builder ,
154
+ char buf [],
155
+ size_t bufsize ,
156
+ int boolean );
161
157
162
158
/**
163
159
* @brief Push a null token to the builder
@@ -167,9 +163,7 @@ JSONB_API jsonbcode jsonb_push_bool(jsonb *builder,
167
163
* @param bufsize the JSON buffer size
168
164
* @return @ref jsonbcode value
169
165
*/
170
- JSONB_API jsonbcode jsonb_push_null (jsonb * builder ,
171
- char buf [],
172
- size_t bufsize );
166
+ JSONB_API jsonbcode jsonb_null (jsonb * builder , char buf [], size_t bufsize );
173
167
174
168
/**
175
169
* @brief Push a string token to the builder
@@ -181,7 +175,7 @@ JSONB_API jsonbcode jsonb_push_null(jsonb *builder,
181
175
* @param len the string length
182
176
* @return @ref jsonbcode value
183
177
*/
184
- JSONB_API jsonbcode jsonb_push_string (
178
+ JSONB_API jsonbcode jsonb_string (
185
179
jsonb * builder , char buf [], size_t bufsize , const char str [], size_t len );
186
180
187
181
/**
@@ -193,10 +187,10 @@ JSONB_API jsonbcode jsonb_push_string(
193
187
* @param number the number to be inserted
194
188
* @return @ref jsonbcode value
195
189
*/
196
- JSONB_API jsonbcode jsonb_push_number (jsonb * builder ,
197
- char buf [],
198
- size_t bufsize ,
199
- double number );
190
+ JSONB_API jsonbcode jsonb_number (jsonb * builder ,
191
+ char buf [],
192
+ size_t bufsize ,
193
+ double number );
200
194
201
195
#ifndef JSONB_HEADER
202
196
#include <stdio.h>
@@ -208,24 +202,15 @@ static const char *
208
202
_jsonb_eval_state (enum jsonbstate state )
209
203
{
210
204
switch (state ) {
211
- case JSONB_ARRAY_OR_OBJECT_OR_VALUE :
212
- return "array or object or value" ;
213
- case JSONB_OBJECT_KEY_OR_CLOSE :
214
- return "object key or close" ;
215
- case JSONB_OBJECT_NEXT_KEY_OR_CLOSE :
216
- return "object next key or close" ;
217
- case JSONB_OBJECT_VALUE :
218
- return "object value" ;
219
- case JSONB_ARRAY_VALUE_OR_CLOSE :
220
- return "array value or close" ;
221
- case JSONB_ARRAY_NEXT_VALUE_OR_CLOSE :
222
- return "array next value or close" ;
223
- case JSONB_ERROR :
224
- return "error" ;
225
- case JSONB_DONE :
226
- return "done" ;
227
- default :
228
- return "unknown" ;
205
+ case JSONB_ARRAY_OR_OBJECT_OR_VALUE : return "array or object or value" ;
206
+ case JSONB_OBJECT_KEY_OR_CLOSE : return "object key or close" ;
207
+ case JSONB_OBJECT_NEXT_KEY_OR_CLOSE : return "object next key or close" ;
208
+ case JSONB_OBJECT_VALUE : return "object value" ;
209
+ case JSONB_ARRAY_VALUE_OR_CLOSE : return "array value or close" ;
210
+ case JSONB_ARRAY_NEXT_VALUE_OR_CLOSE : return "array next value or close" ;
211
+ case JSONB_ERROR : return "error" ;
212
+ case JSONB_DONE : return "done" ;
213
+ default : return "unknown" ;
229
214
}
230
215
}
231
216
#define TRACE (prev , next ) \
@@ -270,7 +255,7 @@ jsonb_init(jsonb *b)
270
255
}
271
256
272
257
jsonbcode
273
- jsonb_push_object (jsonb * b , char buf [], size_t bufsize )
258
+ jsonb_object (jsonb * b , char buf [], size_t bufsize )
274
259
{
275
260
enum jsonbstate new_state ;
276
261
size_t pos = 0 ;
@@ -303,7 +288,7 @@ jsonb_push_object(jsonb *b, char buf[], size_t bufsize)
303
288
}
304
289
305
290
jsonbcode
306
- jsonb_pop_object (jsonb * b , char buf [], size_t bufsize )
291
+ jsonb_object_pop (jsonb * b , char buf [], size_t bufsize )
307
292
{
308
293
enum jsonbcode code ;
309
294
size_t pos = 0 ;
@@ -388,8 +373,7 @@ _jsonb_escape(
388
373
}
389
374
390
375
jsonbcode
391
- jsonb_push_key (
392
- jsonb * b , char buf [], size_t bufsize , const char key [], size_t len )
376
+ jsonb_key (jsonb * b , char buf [], size_t bufsize , const char key [], size_t len )
393
377
{
394
378
size_t pos = 0 ;
395
379
switch (* b -> top ) {
@@ -415,7 +399,7 @@ jsonb_push_key(
415
399
}
416
400
417
401
jsonbcode
418
- jsonb_push_array (jsonb * b , char buf [], size_t bufsize )
402
+ jsonb_array (jsonb * b , char buf [], size_t bufsize )
419
403
{
420
404
enum jsonbstate new_state ;
421
405
size_t pos = 0 ;
@@ -448,7 +432,7 @@ jsonb_push_array(jsonb *b, char buf[], size_t bufsize)
448
432
}
449
433
450
434
jsonbcode
451
- jsonb_pop_array (jsonb * b , char buf [], size_t bufsize )
435
+ jsonb_array_pop (jsonb * b , char buf [], size_t bufsize )
452
436
{
453
437
enum jsonbcode code ;
454
438
size_t pos = 0 ;
@@ -471,7 +455,7 @@ jsonb_pop_array(jsonb *b, char buf[], size_t bufsize)
471
455
}
472
456
473
457
jsonbcode
474
- jsonb_push_token (
458
+ jsonb_token (
475
459
jsonb * b , char buf [], size_t bufsize , const char token [], size_t len )
476
460
{
477
461
enum jsonbstate next_state ;
@@ -507,20 +491,20 @@ jsonb_push_token(
507
491
}
508
492
509
493
jsonbcode
510
- jsonb_push_bool (jsonb * b , char buf [], size_t bufsize , int boolean )
494
+ jsonb_bool (jsonb * b , char buf [], size_t bufsize , int boolean )
511
495
{
512
- if (boolean ) return jsonb_push_token (b , buf , bufsize , "true" , 4 );
513
- return jsonb_push_token (b , buf , bufsize , "false" , 5 );
496
+ if (boolean ) return jsonb_token (b , buf , bufsize , "true" , 4 );
497
+ return jsonb_token (b , buf , bufsize , "false" , 5 );
514
498
}
515
499
516
500
jsonbcode
517
- jsonb_push_null (jsonb * b , char buf [], size_t bufsize )
501
+ jsonb_null (jsonb * b , char buf [], size_t bufsize )
518
502
{
519
- return jsonb_push_token (b , buf , bufsize , "null" , 4 );
503
+ return jsonb_token (b , buf , bufsize , "null" , 4 );
520
504
}
521
505
522
506
jsonbcode
523
- jsonb_push_string (
507
+ jsonb_string (
524
508
jsonb * b , char buf [], size_t bufsize , const char str [], size_t len )
525
509
{
526
510
enum jsonbstate next_state ;
@@ -559,12 +543,12 @@ jsonb_push_string(
559
543
}
560
544
561
545
jsonbcode
562
- jsonb_push_number (jsonb * b , char buf [], size_t bufsize , double number )
546
+ jsonb_number (jsonb * b , char buf [], size_t bufsize , double number )
563
547
{
564
548
char token [32 ];
565
549
long len = sprintf (token , "%.17G" , number );
566
550
if (len < 0 ) return JSONB_ERROR_INPUT ;
567
- return jsonb_push_token (b , buf , bufsize , token , len );
551
+ return jsonb_token (b , buf , bufsize , token , len );
568
552
}
569
553
#endif /* JSONB_HEADER */
570
554
0 commit comments