Closed gouyang closed 5 years ago
Thanks for the report. It’s actually \u003c
and \u003e
, escape sequences for <
and >
. This is a behavior of Golang json.Marshal
, per https://golang.org/pkg/encoding/json/:
The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e" to keep some browsers from misinterpreting JSON output as HTML.
Using raw <
/>
and escaped \u003c
/\u003e
is semantically equivalent, and all JSON consumers should handle the two variants equivalently. Yes, it can look confusing to a human reader.
FWIW skopeo inspect … | python -mjson.tool
can be used to remove the escapes because json.tool
seems to not escape these characters, at least not by default.
We could also (@runcom ?) configure the marshaller in skopeo inspect
with SetEscapeHTML(false)
, but if we are serious about using JSON, at least the "
and \
characters certainly need to be escaped, so we can’t get completely human-readable output either way. For that, we would need to build a GUI which delineates fields using outlines and shading instead of text (and even then we could have serious difficulties due to e.g. right-to-left/left-to-right override control characters).
@mtrmac There is similar issue in project buildah
, it's solved in https://github.com/projectatomic/buildah/pull/421, for your reference.
I don’t really see this as valuable—to an extent, it’s better if human readers are reminded that this is JSON syntax and escapes matter—but I’ll defer to @runcom .
(Thanks for the pointer to working code, though.)
I don’t really see this as valuable—to an extent, it’s better if human readers are reminded that this is JSON syntax and escapes matter—but I’ll defer to @runcom .
I'd leave this is, it's JSON and maybe someone pipe that to a file
If they pipe to a file or to anything other then a TTY it will not change. It is only being done when Humans are looking at it.
That’s how it works in buildah, not in skopeo; anyway, the consensus seems to have been not to disable the escaping.
\u003
and\u003e
shows in inspect command.