Skip to content

convenience method for lossy conversion of lists to vectors #15

@trevor

Description

@trevor

It would be handy to have a settable flag to convert lists to vectors if that level of detail isn't needed. For example:

puts YAML.dump EDN.read('[1 (2 [3 4] #{5 6} {:a 7 :b 8})]')
puts
puts
puts YAML.dump EDN.read('[1 [2 [3 4] #{5 6} {:a 7 :b 8}]]')

---
- 1
- !ruby/array:EDN::Type::List
  - 2
  - - 3
    - 4
  - !ruby/object:Set
    hash:
      5: true
      6: true
  - :a: 7
    :b: 8


---
- 1
- - 2
  - - 3
    - 4
  - !ruby/object:Set
    hash:
      5: true
      6: true
  - :a: 7
    :b: 8

Currently this behavior can be invoked with a one-line change of line 37 in lib/edn/transform.erb:

rule(:list => subtree(:array)) { EDN::Type::List.new(*array) }

to:

rule(:list => subtree(:array)) { array }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions