Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support YAML anchors/aliases on deserialization #20

Closed
Blacksmoke16 opened this issue Jul 24, 2019 · 1 comment · Fixed by #22
Closed

Support YAML anchors/aliases on deserialization #20

Blacksmoke16 opened this issue Jul 24, 2019 · 1 comment · Fixed by #22
Labels
format:yaml kind:bug An existing feature isn't doing something correctly
Milestone

Comments

@Blacksmoke16
Copy link
Owner

With the implementation of #18, YAML input is now streamed, or read token by token as it comes in. This makes supporting aliases/anchors a bit tricky as there isn't way to "back up" the pull parser when an alias is encountered.

Currently there are two way I can see to fix this.

  1. Try to come up with something to keep track of/store the anchored elements and apply them when encountered again.
  2. Revert Yaml.deserialize to simply use the previous logic of loading it into memory to do the conversion.

1 would be most ideal, but 2 wouldn't be the end of the world.

@Blacksmoke16 Blacksmoke16 added kind:bug An existing feature isn't doing something correctly format:yaml status:todo labels Jul 24, 2019
@Blacksmoke16 Blacksmoke16 added this to the 0.2.0 milestone Jul 24, 2019
@Blacksmoke16
Copy link
Owner Author

After giving this some thought, I didn't really come up with any ideas for handling it in a streaming fashion. Plan for now is to replace the deserialize method with:

# OPTIMIZE: Figure out a way to handle aliases/anchors while streaming.
def self.deserialize(input : IO, output : IO, **args) : Nil
  YAML.parse(input).to_json output
end

PRs are welcome if anyone can come up with a solution that would allow for streaming as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format:yaml kind:bug An existing feature isn't doing something correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant