RubyGems Version License Build Dependent tests

Lutaml::Model is a Ruby library for creating information models with attributes and types, providing flexible and comprehensive mechanisms for serializing to and from multiple formats including XML, JSON, YAML, TOML, JSON-LD, Turtle, and Hash.

Key features

  • Model-driven design - Define models with attributes and types

  • Multi-format serialization - XML, JSON, YAML, TOML, JSON-LD, Turtle, Hash, YAML Stream

  • XML namespace support - Full W3C namespace implementation

  • Linked Data support - RDF namespaces, JSON-LD, and Turtle serialization

  • Opal support - Run in the browser via Opal (Ruby to JavaScript) with REXML adapter

  • Validation - Built-in validation with custom rules

  • Schema generation - Generate XSD, JSON Schema, YAML Schema

  • Polymorphism - Handle multiple types elegantly

  • Collections - Work with groups of models

  • Custom types - Extend with your own value types

Getting started

Choose your path:

Installation

Install Lutaml::Model and configure adapters

Quick Start

Create your first model in 5 minutes

Tutorials

Step-by-step guides for progressive learning

Guides

Task-oriented documentation for specific goals

Core Topics

Complete reference for all features

Quick example

require 'lutaml/model'

class Person < Lutaml::Model::Serializable
  attribute :name, :string
  attribute :age, :integer

  xml do
    element "person"
    map_element "name", to: :name
    map_element "age", to: :age
  end

  key_value do
    map "name", to: :name
    map "age", to: :age
  end
end

# Serialize
person = Person.new(name: "John", age: 30)
person.to_xml   # => <person><name>John</name><age>30</age></person>
person.to_json  # => {"name":"John","age":30}

# Deserialize
Person.from_xml(xml_string)
Person.from_json(json_string)

Documentation sections

Core Topics

Fundamental concepts, configuration, and essential features.

Tutorials

Progressive, step-by-step learning from basics to advanced topics.

Guides

Task-oriented guides for accomplishing specific goals.

Reference

Technical reference, architecture, and implementation details.

License

Lutaml::Model is released under the BSD 2-Clause License.

Copyright (c) 2025 Ribose Inc.