Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
json_serializers.h File Reference

JSON serialization helpers for the facade. More...

#include <entropic/mcp/utf8_sanitize.h>
#include <entropic/types/config.h>
#include <entropic/types/message.h>
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
Include dependency graph for json_serializers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string facade_json::serialize_messages (const std::vector< entropic::Message > &messages)
 Serialize messages to JSON array string.
 
nlohmann::json facade_json::parse (const char *str)
 Parse JSON string to nlohmann::json object.
 
nlohmann::json facade_json::obj ()
 Create a JSON object from key-value pairs.
 
nlohmann::json facade_json::arr ()
 Create an empty JSON array.
 
std::string facade_json::serialize_adapter_info (const entropic::AdapterInfo &ai)
 Serialize an AdapterInfo to JSON string.
 
std::string facade_json::serialize_adapter_list (const std::vector< entropic::AdapterInfo > &adapters)
 Serialize a list of AdapterInfo to JSON array string.
 

Detailed Description

JSON serialization helpers for the facade.

Concentrates all nlohmann/json usage in one private facade header. The main entropic.cpp should not include nlohmann/json.hpp directly.

Version
2.0.1

Definition in file json_serializers.h.

Function Documentation

◆ arr()

nlohmann::json facade_json::arr ( )
inline

Create an empty JSON array.

Returns
Empty JSON array. @utility
Version
2.0.1

Definition at line 75 of file json_serializers.h.

◆ obj()

nlohmann::json facade_json::obj ( )
inline

Create a JSON object from key-value pairs.

Returns
Empty JSON object. @utility
Version
2.0.1

Definition at line 67 of file json_serializers.h.

◆ parse()

nlohmann::json facade_json::parse ( const char *  str)
inline

Parse JSON string to nlohmann::json object.

Parameters
strJSON string.
Returns
Parsed JSON (discarded on error). @utility
Version
2.0.1

Definition at line 56 of file json_serializers.h.

◆ serialize_adapter_info()

std::string facade_json::serialize_adapter_info ( const entropic::AdapterInfo ai)
inline

Serialize an AdapterInfo to JSON string.

Parameters
aiAdapter info struct.
Returns
JSON object string. @utility
Version
2.0.1

Definition at line 84 of file json_serializers.h.

◆ serialize_adapter_list()

std::string facade_json::serialize_adapter_list ( const std::vector< entropic::AdapterInfo > &  adapters)
inline

Serialize a list of AdapterInfo to JSON array string.

Parameters
adaptersAdapter info list.
Returns
JSON array string. @utility
Version
2.0.1

Definition at line 104 of file json_serializers.h.

◆ serialize_messages()

std::string facade_json::serialize_messages ( const std::vector< entropic::Message > &  messages)
inline

Serialize messages to JSON array string.

Sanitizes content through entropic::mcp::sanitize_utf8 before each push so that any bytes which slipped past the inbound sanitize boundaries (model-stream desync, pre-2.1.1 audit-replayed history, pre-2.1.1 stored conversation state) cannot reach arr.dump() and raise json::type_error 316. This is the C-API outbound boundary; see include/entropic/mcp/utf8_sanitize.h for the full boundary policy. Issue #3 (v2.1.1).

Parameters
messagesMessage vector.
Returns
JSON array string. @utility
Version
2.1.1

Definition at line 39 of file json_serializers.h.