3. 语法 (Syntax)
3. 语法 (Syntax)
JSON Pointer 是一个 Unicode string (见 [RFC4627] 第 3 节), 包含零个或多个 reference tokens 的序列, 每个 token 前都有一个 '/' (%x2F) 字符.
由于字符 '' (%x7E) 和 '/' (%x2F) 在 JSON Pointer 中有特殊含义, 当这些字符出现在 reference token 中时, '' 需要编码为 '~0', '/' 需要编码为 '~1'.
JSON Pointer 的 ABNF 语法为:
json-pointer = *( "/" reference-token )
reference-token = *( unescaped / escaped )
unescaped = %x00-2E / %x30-7D / %x7F-10FFFF
; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'
escaped = "~" ( "0" / "1" )
; representing '~' and '/', respectively
如果 JSON Pointer 值不符合此语法, 则属于错误条件 (见第 7 节).
注意, JSON Pointers 以字符而不是字节来规定.