JSON Encode
The json::encode
function converts a structured object, such as a map or list, into a JSON string.
Syntax
json::encode(<object>)
Parameters
object
: The structured object (map or list) to encode into JSON format.
Returns
- String: A JSON string representation of the input object.
Example
json::encode({"name": "Alice", "age": 30})
This function is useful for creating JSON payloads for API requests or storing structured data as JSON.