Skip to content

Support readable untyped recursive object encoding as the default documented mode #35

@konard

Description

@konard

Problem

lino-objects-codec@0.3.6 currently documents and exports the typed object codec as the primary encode/decode path. The generated notation preserves JavaScript types, but it is much harder to review because it emits markers such as object, str, int, and base64 strings.

For reviewable repository data files, an untyped/dynamic recursive object mode is needed as the default documented path, with the typed codec still available when exact JavaScript type preservation is required.

Expected readable shape:

obj_root:
  title `Indian Law`
  defaultLanguage en
  maxLines 1500
  sourceMetadata obj_root_source_metadata
  languages obj_root_languages

obj_root_source_metadata:
  generatedFrom obj_root_source_metadata_generated_from
  lastVerified 2026-05-10

Reproduction

import { encode, jsonToLino, linoToJson, formatIndented } from "lino-objects-codec";

const data = {
  title: "Indian Law",
  defaultLanguage: "en",
  maxLines: 1500,
  nested: { ok: true },
  items: ["a", 1]
};

console.log(encode({ obj: data }));
console.log(jsonToLino({ json: data }));
console.log(linoToJson({ lino: jsonToLino({ json: data }) }));
console.log(formatIndented({ id: "obj_root", obj: data }));

Observed with 0.3.6:

(object ((str dGl0bGU=) (str SW5kaWFuIExhdw==)) ((str ZGVmYXVsdExhbmd1YWdl) (str ZW4=)) ((str bWF4TGluZXM=) (int 1500)) ((str bmVzdGVk) (object ((str b2s=) (bool true)))) ((str aXRlbXM=) (array (str YQ==) (int 1))))

jsonToLino provides compact untyped dynamic notation and linoToJson parses it back, which is useful. However:

  • the README quick start still favors the typed/base64 object codec;
  • formatIndented is flat-only and converts nested objects/arrays to strings such as [object Object] and a,1;
  • there is no out-of-the-box recursive indented untyped writer/parser matching the reviewable form above.

Workaround

Projects can implement a local recursive writer/parser on top of links-notation, or use jsonToLino/linoToJson when compact one-line-ish notation is acceptable.

Suggested Fix

  • Add a recursive untyped dynamic object codec for human-readable repository data.
  • Make the README and examples favor that readable dynamic mode by default.
  • Keep the current typed encode/decode API available and documented for exact type-preserving serialization, circular references, and object identity.
  • Extend formatIndented/parseIndented, or add new named functions, so nested objects and arrays can round-trip without [object Object] stringification.

This would let data catalogs use readable Links Notation by default while still preserving the typed codec for cases that need it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions