Skip to content

How to unmarshal a string or a struct value? #338

Open
@livingsilver94

Description

@livingsilver94

For example, take a look at docker-compose file. build can be a string or a struct, and that's perfectly valid. To unmarshal such a situtation, I thought I could try to unmarshal a string before, and then a struct if the former errored out. Unfortunately I found out that TypeError exists, but it's internal:

https://github.com/goccy/go-yaml/blob/v1.9.8/internal/errors/error.go#L225

Could you expose it, or suggest me an alternative way to unmarshal a value which may be of two different types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions