Skip to content

transform.Unmarshal should allow to specify a format #13887

@n1xx1

Description

@n1xx1

Currently transform.Unmarshal allows to either provide a string or a resource. In the first case the format is inferred from the string, but it may be more useful to be able to specify it. For example json has precedence over yaml, so something like {p: [a, b]} would fail since it’s not valid json but is valid yaml. My current solution for this is to make a temporary resource with a .yaml extension and pass that to Unmarshal. This solution is needlessly complicated and more expensive.

I propose to add a "format" key to the option dict so that it can be used like this:

{{ $opts := dict "format" "yaml" }}
{{ $parsed := "{p: [a, b]}” | unmarshal $opts }}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions