Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util/Unmarshal: if it's JSON, skip YAMLtoJSON (#4681)
This helper accepts JSON or YAML, and used to do this: 1. For YAML input, yaml.YAMLToJSON would parse it as yaml, marshal it to JSON, and pass that back out to be passed to UnmarshalJSON 2. For JSON input, yaml.YAMLToJSON would also parse it as yaml, marshal it to JSON, and pass that back out to UnmarshalJSON Issue #4673 has shown that the theoretical "superset" propery of YAML doesn't seem to hold in all cases. So now, we'll do this: 1. For YAML input, yaml.YAMLToJSON would parse it as yaml, marshal it to JSON, and pass that back out to be passed to UnmarshalJSON 2. For JSON input, json.Valid will determine that it's JSON, and we'll feed it into UnmarshalJSON as-is. The YAML path (1.) still seems suboptimal, but I also suspect that JSON is more common. Also, this change shouldn't make the YAML path much worse: determining that yaml string isn't valid JSON should be quick. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
- Loading branch information