Class: Lutaml::UmlRepository::Exporters::JsonExporter

Inherits:
BaseExporter
  • Object
show all
Defined in:
lib/lutaml/uml_repository/exporters/json_exporter.rb

Overview

Export UML repository to JSON format.

Exports the complete UML model as JSON, preserving all relationships and metadata. Supports filtering by package and optional pretty printing.

Examples:

Basic export

exporter = JsonExporter.new(repository)
exporter.export("model.json")

Pretty-printed export

exporter.export("model.json", pretty: true)

Export specific package

exporter.export("model.json", package: "ModelRoot::i-UR::urf")

Instance Attribute Summary

Attributes inherited from BaseExporter

#repository

Instance Method Summary collapse

Methods inherited from BaseExporter

#initialize

Constructor Details

This class inherits a constructor from Lutaml::UmlRepository::Exporters::BaseExporter

Instance Method Details

#export(output_path, options = {}) ⇒ void

This method returns an undefined value.

Export repository to JSON format.

Parameters:

  • output_path (String)

    Path to the output JSON file

  • options (Hash) (defaults to: {})

    Export options

Options Hash (options):

  • :pretty (Boolean) — default: true

    Pretty-print JSON

  • :package (String)

    Filter by package path

  • :recursive (Boolean) — default: false

    Include nested packages when filtering

  • :include_diagrams (Boolean) — default: true

    Include diagram metadata



36
37
38
39
40
# File 'lib/lutaml/uml_repository/exporters/json_exporter.rb', line 36

def export(output_path, options = {})
  data = build_export_data(options)

  File.write(output_path, format_json(data, options))
end