ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::core::json_export Namespace Reference

Classes

struct  SectionDescriptor
 Describes a section in the JSON export template. More...

Functions

std::span< const SectionDescriptorsection_descriptors ()
 Get the section descriptors in JSON template order.
nlohmann::json to_json (const MaterialPassport &passport)
 Export a single MaterialPassport to JSON.
nlohmann::json to_json_with_defaults (const MaterialPassport &passport)
 Export a single MaterialPassport to JSON with sensible defaults.
nlohmann::json generate_blank_template ()
 Generate a blank MaterialPassport template as JSON.
nlohmann::json to_json (const std::vector< MaterialPassport > &passports)
 Export multiple MaterialPassports to a JSON array.
std::string to_json_string (const MaterialPassport &passport, int indent=4)
 Export a single passport as a formatted JSON string.
std::string to_json_string (const std::vector< MaterialPassport > &passports, int indent=4)
 Export multiple passports as a formatted JSON string.

Function Documentation

◆ generate_blank_template()

nlohmann::json reusex::core::json_export::generate_blank_template ( )
nodiscard

Generate a blank MaterialPassport template as JSON.

Creates a complete template with all 10 sections and all properties present, with empty values for user to fill in. Useful for creating new material passports from scratch.

Template characteristics:

  • All sections present with all properties
  • All string fields: "" (empty for user to fill)
  • All vectors: [] (empty arrays)
  • All optionals: unset (will show as "")
  • Metadata: Auto-generated GUID, current date, version "0.1.0"
  • Transaction log: [] (empty)
Returns
JSON template object

◆ section_descriptors()

std::span< const SectionDescriptor > reusex::core::json_export::section_descriptors ( )

Get the section descriptors in JSON template order.

Returns 10 sections in the order defined by the Danish standard: Owner, ConstructionItemDescription, ProductInformation, Certifications, Dimensions, History, Condition, Pollution, EnvironmentalPotential, FireProperties

Returns
Span of SectionDescriptor instances

◆ to_json() [1/2]

nlohmann::json reusex::core::json_export::to_json ( const MaterialPassport & passport)
nodiscard

Export a single MaterialPassport to JSON.

Produces a JSON object matching the Danish "Materialepas for genbrugte byggevarer" interchange format with sections, log, and metadata.

Parameters
passportThe passport to export
Returns
JSON object

◆ to_json() [2/2]

nlohmann::json reusex::core::json_export::to_json ( const std::vector< MaterialPassport > & passports)
nodiscard

Export multiple MaterialPassports to a JSON array.

Each element in the array is a full passport JSON object.

Parameters
passportsVector of passports to export
Returns
JSON array

◆ to_json_string() [1/2]

std::string reusex::core::json_export::to_json_string ( const MaterialPassport & passport,
int indent = 4 )
nodiscard

Export a single passport as a formatted JSON string.

Parameters
passportThe passport to export
indentNumber of spaces for indentation (default: 4)
Returns
Formatted JSON string

◆ to_json_string() [2/2]

std::string reusex::core::json_export::to_json_string ( const std::vector< MaterialPassport > & passports,
int indent = 4 )
nodiscard

Export multiple passports as a formatted JSON string.

Parameters
passportsVector of passports to export
indentNumber of spaces for indentation (default: 4)
Returns
Formatted JSON string

◆ to_json_with_defaults()

nlohmann::json reusex::core::json_export::to_json_with_defaults ( const MaterialPassport & passport)
nodiscard

Export a single MaterialPassport to JSON with sensible defaults.

Similar to to_json(), but populates missing optional fields with sensible defaults to improve readability:

  • optional<bool> fields → false (explicit "no")
  • Empty vectors → [] (truly empty, no template entries)
  • TriState → unchanged (unknown, yes, no)
  • Numeric optionals → "" (ambiguous whether 0 means zero or unknown)

This is useful for exporting partial passports in a user-friendly format.

Parameters
passportThe passport to export
Returns
JSON object with defaults populated