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

Doesn't it yet have the ability to add arbitrary tags? #23

Closed
kbaba1001 opened this issue Jul 19, 2021 · 3 comments · Fixed by #49
Closed

Doesn't it yet have the ability to add arbitrary tags? #23

kbaba1001 opened this issue Jul 19, 2021 · 3 comments · Fixed by #49

Comments

@kbaba1001
Copy link

I tried using tags like next, but I got an error.

(require '[clj-yaml.core :as yaml])
(yaml/parse-string "
- name: !foo Mary Smith
")

error:

Execution error (ConstructorException) at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructUndefined/construct (SafeConstructor.java:539).
could not determine a constructor for the tag !foo
 in 'string', line 2, column 9:
    - name: !foo Mary Smith

I read the source code, I found the TODO comment:
https://github.com/clj-commons/clj-yaml/blob/master/src/clojure/clj_yaml/core.clj#L59

Does this comment mean that it doesn't yet have the ability to add arbitrary tags?

@The-Alchemist
Copy link

The-Alchemist commented Sep 30, 2021

I think clj-yaml doesn't expose the addImplicitResolver() method of snakeyaml. See https://bitbucket.org/asomov/snakeyaml/src/5e41c378e49c9b363055ac8b0386b69cb3f389d2/src/main/java/org/yaml/snakeyaml/resolver/Resolver.java#lines-89

That's OK, you might be able to call it manually (haven't checked the code), or you might be able to just create a class called foo using deftype.

Better question for https://ask.clojure.org/ :)

@borkdude
Copy link
Collaborator

clj-yaml should probably support this. Feel free to make proposals, starting with a clear problem statement and with several alternatives.

@borkdude
Copy link
Collaborator

@grzm This issue is related to your request. PassthroughConstructor should also help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants