Skip to content

Refactor: remove assumption that the document root is an object #55

Description

@dakusui

Summary

Several parts of jq++ currently assume the processed document root is a JSON object
(map[string]any). That assumption is broader than issue #54 and should be removed
as an intermediate refactor before adding support for top-level YAML sequences.

Why this matters

Issue #54 surfaces this as a YAML problem, but the structural constraint is not
YAML-specific. The current pipeline expects an object root in multiple places:

  • file loading and decoding
  • inheritance resolution entry points
  • key-side/value-side processing
  • CLI processing/output path

As long as this assumption remains, support for top-level sequences is awkward to
add and likely to be incomplete.

Scope

Refactor the processing pipeline so the root document can be any JSON-compatible
value:

  • object
  • array
  • string
  • number
  • boolean
  • null

Object-only features such as $extends, $includes, and $local should remain
object-only and be applied only where semantically valid.

Expected outcome

After this refactor:

  • the loader and main processing flow accept non-object roots
  • traversal/evaluation logic works from arbitrary roots
  • inheritance directives still behave correctly for object nodes
  • follow-up work for issue jq++ cannot process top-level YAML sequences #54 becomes a narrower change focused on YAML top-level sequences

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions