6. URI 片段标识符表示 (URI Fragment Identifier Representation)
6. URI 片段标识符表示 (URI Fragment Identifier Representation)
JSON Pointer 可以表示在 URI fragment identifier 中: 先使用 UTF-8 [RFC3629] 将其编码为 octets, 同时对 [RFC3986] 中 fragment 规则不允许的字符进行 percent-encoding.
注意, 给定的 media type 需要显式指定 JSON Pointer 作为其 fragment identifier syntax, 通常在其注册项 [RFC6838] 中指定. 也就是说, 文档是 JSON 并不意味着 JSON Pointer 可用作其 fragment identifier syntax. 特别是, application/json 的 fragment identifier syntax 不是 JSON Pointer.
给定与上文相同的示例文档, 以下 URI fragment identifiers 会求值得到相应的值:
# // the whole document
#/foo ["bar", "baz"]
#/foo/0 "bar"
#/ 0
#/a~1b 1
#/c%25d 2
#/e%5Ef 3
#/g%7Ch 4
#/i%5Cj 5
#/k%22l 6
#/%20 7
#/m~0n 8