FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
Functions
fdl_canonical.cpp File Reference

Canonical JSON serialization – null stripping, key reordering per FDL spec, formatting. More...

#include "fdl_canonical.h"
#include "fdl_compat.h"
#include <cstring>

Functions

ojson fdl::detail::strip_nulls (const ojson &val)
 Strip null values recursively; empty arrays are preserved as [].
 
ojson fdl::detail::reorder_object (const ojson &obj, const std::string &type_hint)
 Reorder an object's keys according to the specified type's canonical order.
 
char * fdl::detail::node_to_canonical_json (const ojson *node, const std::string &type_hint, int indent)
 Serialize an ojson node to canonical JSON: strip_nulls + reorder + format.
 

Detailed Description

Canonical JSON serialization – null stripping, key reordering per FDL spec, formatting.

Function Documentation

◆ strip_nulls()

ojson fdl::detail::strip_nulls ( const ojson val)

Strip null values recursively; empty arrays are preserved as [].

Parameters
valJSON value to process.
Returns
Copy of val with all null members removed.

◆ reorder_object()

ojson fdl::detail::reorder_object ( const ojson obj,
const std::string &  type_hint 
)

Reorder an object's keys according to the specified type's canonical order.

Parameters
objJSON object to reorder.
type_hintObject type: "root", "context", "canvas", "framing_decision", "framing_intent", "canvas_template", "version", "dimensions", "point", "round_strategy", "clip_id".
Returns
New object with keys in canonical order.

◆ node_to_canonical_json()

char * fdl::detail::node_to_canonical_json ( const ojson node,
const std::string &  type_hint,
int  indent 
)

Serialize an ojson node to canonical JSON: strip_nulls + reorder + format.

Parameters
nodeJSON node to serialize (may be nullptr).
type_hintType hint for key ordering.
indentSpaces per indent level (0 for compact).
Returns
Heap-allocated C string (caller owns, free with fdl_free / std::free). Returns nullptr if node is nullptr.

< POSIX strdup.