Couchbase Lite C
Couchbase Lite C API
|
#include "FLBase.h"
Go to the source code of this file.
Macros | |
#define | _FLJSON_H |
Functions | |
Converting to JSON | |
These are convenience functions that directly return a JSON representation of a value. For more control over the encoding, use an Fleece Encoders with format kFLEncodeJSON. | |
FLEECE_PUBLIC FLStringResult | FLValue_ToJSON (FLValue FL_NULLABLE) |
Encodes a Fleece value as JSON (or a JSON fragment.) More... | |
FLEECE_PUBLIC FLStringResult | FLValue_ToJSON5 (FLValue FL_NULLABLE) |
Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric. More... | |
FLEECE_PUBLIC FLStringResult | FLValue_ToJSONX (FLValue FL_NULLABLE v, bool json5, bool canonicalForm) |
Most general Fleece to JSON converter. More... | |
Parsing JSON to Fleece Values | |
NODISCARD FLEECE_PUBLIC FLDoc | FLDoc_FromJSON (FLSlice json, FLError *FL_NULLABLE outError) |
Creates an FLDoc from JSON-encoded data. More... | |
NODISCARD FLEECE_PUBLIC FLMutableArray FL_NULLABLE | FLMutableArray_NewFromJSON (FLString json, FLError *FL_NULLABLE outError) |
Creates a new mutable Array from JSON. More... | |
NODISCARD FLEECE_PUBLIC FLMutableDict FL_NULLABLE | FLMutableDict_NewFromJSON (FLString json, FLError *FL_NULLABLE outError) |
Creates a new mutable Dict from json. More... | |
FLEECE_PUBLIC bool | FLEncoder_ConvertJSON (FLEncoder, FLSlice json) |
Parses JSON data and writes the value(s) to the encoder as their Fleece equivalents. More... | |
#define _FLJSON_H |
NODISCARD FLEECE_PUBLIC FLDoc FLDoc_FromJSON | ( | FLSlice | json, |
FLError *FL_NULLABLE | outError | ||
) |
Creates an FLDoc from JSON-encoded data.
The data is first encoded into Fleece, and the Fleece data is kept by the doc; the input JSON data is no longer needed after this function returns.
FLEECE_PUBLIC bool FLEncoder_ConvertJSON | ( | FLEncoder | , |
FLSlice | json | ||
) |
Parses JSON data and writes the value(s) to the encoder as their Fleece equivalents.
(This acts as a single write, like WriteInt; it's just that the value written is likely to be an entire dictionary or array.)
NODISCARD FLEECE_PUBLIC FLMutableArray FL_NULLABLE FLMutableArray_NewFromJSON | ( | FLString | json, |
FLError *FL_NULLABLE | outError | ||
) |
Creates a new mutable Array from JSON.
It is an error if the JSON is not an array. Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.
NODISCARD FLEECE_PUBLIC FLMutableDict FL_NULLABLE FLMutableDict_NewFromJSON | ( | FLString | json, |
FLError *FL_NULLABLE | outError | ||
) |
Creates a new mutable Dict from json.
It is an error if the JSON is not a dictionary/object. Its initial ref-count is 1, so a call to FLMutableDict_Release will free it.
FLEECE_PUBLIC FLStringResult FLValue_ToJSON | ( | FLValue | FL_NULLABLE | ) |
Encodes a Fleece value as JSON (or a JSON fragment.)
FLEECE_PUBLIC FLStringResult FLValue_ToJSON5 | ( | FLValue | FL_NULLABLE | ) |
Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric.
This tends to be more readable.
FLEECE_PUBLIC FLStringResult FLValue_ToJSONX | ( | FLValue FL_NULLABLE | v, |
bool | json5, | ||
bool | canonicalForm | ||
) |
Most general Fleece to JSON converter.
v | The Fleece value to encode |
json5 | If true, outputs JSON5, like FLValue_ToJSON5 |
canonicalForm | If true, outputs the JSON in a consistent "canonical" form. All equivalent values should produce byte-for-byte identical canonical JSON. This is useful for creating digital signatures, for example. |