iceberg-cpp
Loading...
Searching...
No Matches
Functions
json_serde_internal.h File Reference
#include <nlohmann/json_fwd.hpp>
#include "iceberg/expression/expression.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"
#include "iceberg/type_fwd.h"

Go to the source code of this file.

Functions

Result< Expression::Operationiceberg::OperationTypeFromJson (const nlohmann::json &json)
 Converts an operation type string to an Expression::Operation.
 
nlohmann::json iceberg::ToJson (Expression::Operation op)
 Converts an Expression::Operation to its json representation.
 
Result< std::shared_ptr< Expression > > iceberg::ExpressionFromJson (const nlohmann::json &json, const Schema *schema=nullptr)
 Deserializes a JSON object into an Expression.
 
Result< nlohmann::json > iceberg::ToJson (const Expression &expr)
 Serializes an Expression into its JSON representation.
 
Result< std::unique_ptr< NamedReference > > iceberg::NamedReferenceFromJson (const nlohmann::json &json)
 Deserializes a JSON object into a NamedReference.
 
nlohmann::json iceberg::ToJson (const NamedReference &ref)
 Serializes a NamedReference into its JSON representation.
 
nlohmann::json iceberg::ToJson (const UnboundTransform &transform)
 Serializes an UnboundTransform into its JSON representation.
 
Result< std::unique_ptr< UnboundTransform > > iceberg::UnboundTransformFromJson (const nlohmann::json &json)
 Deserializes a JSON object into an UnboundTransform.
 
Result< nlohmann::json > iceberg::ToJson (const Literal &literal)
 Serializes a Literal into its JSON representation.
 
Result< Literaliceberg::LiteralFromJson (const nlohmann::json &json)
 Deserializes a JSON value into a Literal.
 
Result< Literaliceberg::LiteralFromJson (const nlohmann::json &json, const Type *type)
 Deserializes a JSON value into a Literal with optional type context.
 
Result< nlohmann::json > iceberg::ToJson (const UnboundPredicate &pred)
 Serializes an UnboundPredicate into its JSON representation.
 
nlohmann::json iceberg::ToJson (const BoundReference &ref)
 Serializes a BoundReference into its JSON representation (field name string).
 
nlohmann::json iceberg::ToJson (const BoundTransform &transform)
 Serializes a BoundTransform into its JSON representation.
 
Result< nlohmann::json > iceberg::ToJson (const BoundPredicate &pred)
 Serializes a BoundPredicate into its JSON representation.
 
Result< std::unique_ptr< UnboundPredicate > > iceberg::UnboundPredicateFromJson (const nlohmann::json &json, const Schema *schema=nullptr)
 Deserializes a JSON object into an UnboundPredicate.
 
Result< nlohmann::json > iceberg::ToJson (const Term &term)
 Serializes a Term into its JSON representation.
 
bool iceberg::IsUnaryOperation (Expression::Operation op)
 Check if an operation is a unary predicate.
 
bool iceberg::IsSetOperation (Expression::Operation op)
 Check if an operation is a set predicate.
 

Detailed Description

JSON serialization and deserialization for expressions.

Function Documentation

◆ ExpressionFromJson()

ICEBERG_EXPORT Result< std::shared_ptr< Expression > > iceberg::ExpressionFromJson ( const nlohmann::json &  json,
const Schema schema = nullptr 
)

Deserializes a JSON object into an Expression.

Parameters
jsonA JSON object representing an expression
schemaOptional schema used to bind field references and coerce literal types.
Returns
A shared pointer to the deserialized Expression or an error

◆ LiteralFromJson() [1/2]

ICEBERG_EXPORT Result< Literal > iceberg::LiteralFromJson ( const nlohmann::json &  json)

Deserializes a JSON value into a Literal.

Parameters
jsonA JSON value representing a literal.
Returns
The deserialized Literal or an error.

◆ LiteralFromJson() [2/2]

ICEBERG_EXPORT Result< Literal > iceberg::LiteralFromJson ( const nlohmann::json &  json,
const Type type 
)

Deserializes a JSON value into a Literal with optional type context.

Parameters
jsonA JSON value representing a literal.
typeOptional target type used to guide parsing.
Returns
The deserialized Literal or an error.

◆ NamedReferenceFromJson()

ICEBERG_EXPORT Result< std::unique_ptr< NamedReference > > iceberg::NamedReferenceFromJson ( const nlohmann::json &  json)

Deserializes a JSON object into a NamedReference.

Parameters
jsonA JSON object representing a named reference
Returns
A shared pointer to the deserialized NamedReference or an error

◆ OperationTypeFromJson()

ICEBERG_EXPORT Result< Expression::Operation > iceberg::OperationTypeFromJson ( const nlohmann::json &  json)

Converts an operation type string to an Expression::Operation.

Parameters
typeStrThe operation type string
Returns
The corresponding Operation or an error if unknown

◆ ToJson() [1/7]

ICEBERG_EXPORT Result< nlohmann::json > iceberg::ToJson ( const Expression expr)

Serializes an Expression into its JSON representation.

Parameters
exprThe expression to serialize
Returns
A JSON object representing the expression, or an error

◆ ToJson() [2/7]

ICEBERG_EXPORT Result< nlohmann::json > iceberg::ToJson ( const Literal literal)

Serializes a Literal into its JSON representation.

Parameters
literalThe literal to serialize
Returns
A JSON value representing the literal, or an error

◆ ToJson() [3/7]

ICEBERG_EXPORT nlohmann::json iceberg::ToJson ( const NamedReference ref)

Serializes a NamedReference into its JSON representation.

Parameters
refThe named reference to serialize
Returns
A JSON object representing the named reference, or an error

◆ ToJson() [4/7]

ICEBERG_EXPORT Result< nlohmann::json > iceberg::ToJson ( const Term term)

Serializes a Term into its JSON representation.

Parameters
termThe term to serialize (NamedReference or UnboundTransform)
Returns
A JSON value representing the term, or an error

◆ ToJson() [5/7]

ICEBERG_EXPORT Result< nlohmann::json > iceberg::ToJson ( const UnboundPredicate pred)

Serializes an UnboundPredicate into its JSON representation.

Parameters
predThe unbound predicate to serialize
Returns
A JSON object representing the predicate, or an error

◆ ToJson() [6/7]

ICEBERG_EXPORT nlohmann::json iceberg::ToJson ( const UnboundTransform transform)

Serializes an UnboundTransform into its JSON representation.

Parameters
transformThe unbound transform to serialize
Returns
A JSON object representing the unbound transform, or an error

◆ ToJson() [7/7]

ICEBERG_EXPORT nlohmann::json iceberg::ToJson ( Expression::Operation  op)

Converts an Expression::Operation to its json representation.

Parameters
opThe operation to convert
Returns
The operation type string (e.g., "eq", "lt-eq", "is-null")

◆ UnboundPredicateFromJson()

ICEBERG_EXPORT Result< std::unique_ptr< UnboundPredicate > > iceberg::UnboundPredicateFromJson ( const nlohmann::json &  json,
const Schema schema = nullptr 
)

Deserializes a JSON object into an UnboundPredicate.

Parameters
jsonA JSON object representing an unbound predicate
schemaOptional schema used to resolve literal types.
Returns
A pointer to the deserialized UnboundPredicate or an error

◆ UnboundTransformFromJson()

ICEBERG_EXPORT Result< std::unique_ptr< UnboundTransform > > iceberg::UnboundTransformFromJson ( const nlohmann::json &  json)

Deserializes a JSON object into an UnboundTransform.

Parameters
jsonA JSON object representing an unbound transform
Returns
A shared pointer to the deserialized UnboundTransform or an error