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

[Question] Coerce types #632

Closed
chrisdrobison opened this issue Aug 18, 2021 · 1 comment
Closed

[Question] Coerce types #632

chrisdrobison opened this issue Aug 18, 2021 · 1 comment

Comments

@chrisdrobison
Copy link

I'm working with a library that is expecting a specific generic structure. I'd like any dictionary to come out as a Dictionary<string, object> and any list to be either a List or List<Dictionary<string, object>> depending on the context. Is there a good extension point for this? I've been looking at examples and I can get the dictionary where I want it, but the list is proving to be a lot harder. Any suggestions?

@EdwardCooke
Copy link
Collaborator

Per the yaml spec, there's no guarantee that the key to a value is going to be a string and there's no extension point to set the return type that I am aware of. You would need to build that resulting structure your self. Take a look here for recursively going through object returned by the non generic Deserialize method and pulling keys and values. It might give you a good starting point.

#686 (comment)

If you have additional comments or questions, don't hesitate to re-open this issue. I'll help where I can.

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

No branches or pull requests

2 participants