jpsim / Yams

A Sweet and Swifty YAML parser.
https://jpsim.com/Yams
MIT License
1.12k stars 144 forks source link

Adds the ability to access a Node's `tag` during decoding #352

Open ssgutierrez42 opened 2 years ago

ssgutierrez42 commented 2 years ago

Summary

Enables access of a Node's tag: e.g. !DanceEvent

structure:
  version: 0.1.0
  actions:
    8a139ac7: !DanceEvent
      type: happy

During the decoding function of Codable objects:

 required init(from decoder: Decoder) throws {
      ...
      print("\(decoder.tag)") //!DanceEvent
      ...

Background

See https://github.com/jpsim/Yams/issues/265

Enables an avenue to decode polymorphic types.