Json and Bson convert to each other.
More...
#include "cJSON.h"
#include "bson/bson.h"
Go to the source code of this file.
|
|
SDB_EXPORT void | JsonSetPrintfLog (void(*pFun)(const CHAR *pFunc, const CHAR *pFile, UINT32 line, const CHAR *pFmt,...)) |
| |
|
SDB_EXPORT BOOLEAN | jsonToBson (bson *bs, const CHAR *json_str) |
| |
|
SDB_EXPORT BOOLEAN | jsonToBson2 (bson *bs, const CHAR *json_str, BOOLEAN isMongo, BOOLEAN isBatch) |
| |
| SDB_EXPORT BOOLEAN | json2bson2 (const CHAR *pJson, bson *pBson) |
| | Json converts to bson.
|
| |
| SDB_EXPORT BOOLEAN | json2bson (const CHAR *pJson, CJSON_MACHINE *pMachine, INT32 parseMode, BOOLEAN isCheckEnd, BOOLEAN isUnicode, bson *pBson) |
| | Json converts to bson.
|
| |
|
SDB_EXPORT void | setJsonPrecision (const CHAR *pFloatFmt) |
| |
| SDB_EXPORT BOOLEAN | bsonToJson (CHAR *buffer, INT32 bufsize, const bson *b, BOOLEAN toCSV, BOOLEAN skipUndefined) |
| | Bson converts to json.
|
| |
| SDB_EXPORT BOOLEAN | bsonToJson2 (CHAR *buffer, INT32 bufsize, const bson *b, BOOLEAN isStrict) |
| | Bson converts to json.
|
| |
Json and Bson convert to each other.
| BOOLEAN bsonToJson |
( |
CHAR * |
buffer, |
|
|
INT32 |
bufsize, |
|
|
const bson * |
b, |
|
|
BOOLEAN |
toCSV, |
|
|
BOOLEAN |
skipUndefined |
|
) |
| |
Bson converts to json.
- Parameters
-
| [in] | buffer | the buffer to convert |
| [in] | bufsize | the buffer's size |
| [in] | b | The bson object to convert |
| [in] | toCSV | bson to csv or not |
| [in] | skipUndefined | to skip undefined filed or not |
| [out] | buffer | The return json string |
- Return values
-
| TRUE | Operation Success |
| FALSE | Operation Fail |
- Note
- Before calling this funtion,need to build up a buffer for the convertion result.
| BOOLEAN bsonToJson2 |
( |
CHAR * |
buffer, |
|
|
INT32 |
bufsize, |
|
|
const bson * |
b, |
|
|
BOOLEAN |
isStrict |
|
) |
| |
Bson converts to json.
- Parameters
-
| [in] | buffer | the buffer to convert |
| [in] | bufsize | the buffer's size |
| [in] | b | The bson object to convert |
| [in] | isStrict | Strict export of data types |
| [out] | buffer | The return json string |
- Return values
-
| TRUE | Operation Success |
| FALSE | Operation Fail |
- Note
- Before calling this funtion,need to build up a buffer for the convertion result.
| BOOLEAN json2bson |
( |
const CHAR * |
pJson, |
|
|
CJSON_MACHINE * |
pMachine, |
|
|
INT32 |
parseMode, |
|
|
BOOLEAN |
isCheckEnd, |
|
|
BOOLEAN |
isUnicode, |
|
|
bson * |
pBson |
|
) |
| |
Json converts to bson.
- Parameters
-
| [in] | pJson | The json string to convert |
| [in] | pMachine | The json parse state machine |
| [in] | parseMode | The json parse mode, 0:loose mode; 1:rigorous mode; |
| [in] | isCheckEnd | whether to check the end of json |
| [in] | isUnicode | whether to escape Unicode encoding |
| [out] | pBson | The return bson object |
- Return values
-
| TRUE | Operation Success |
| FALSE | Operation Fail |
| BOOLEAN json2bson2 |
( |
const CHAR * |
pJson, |
|
|
bson * |
pBson |
|
) |
| |
Json converts to bson.
- Parameters
-
| [in] | pJson | The json string to convert |
| [out] | pBson | The return bson object |
- Return values
-
| TRUE | Operation Success |
| FALSE | Operation Fail |