Skip to content

Commit

Permalink
update README: Format Check
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Jun 15, 2022
1 parent d427e9b commit 952da41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,27 @@ previewView.preview(json, style: style)

### Rendering

For rendering, `JSONPreview` performs only **limited** formatting checks, including.

> None of the `previous nodes` mentioned below include `spaces`, `\t`, and `\n`.
- The JSON to be previewed must start with `{` or `[`.
- The previous node of `:` must be `.string`.
- The previous node of `,` can only be one of `.null`, `.link`, `.string`, `.number`, `.boolean`, `}`, and `]`.
- `{` must have a preceding node, and the preceding node must not be `{`.
- `}` must appear in pairs with `{`.
- `[` must exist for the previous node, and the previous node cannot be `]`.
- `]` must occur in pairs with `[`.
- `"` must occur in pairs.
- The previous node of `"` can only be one of `{`, `[`, `,` and `:`.
- Spell checking for `null`, `true`, and `false`.
For rendering, `JSONPreview` only performs **limited** formatting checks.

The conditions that are known to trigger `Error Rendering` include

- Value Unconventional JSON types. Supported types include `object`, `array`, `number`, `bool`, `string`, and `null`.
- Checks for the `number` format, such as scientific notation and decimals.
- Spell checking for `true`, `false` and `null`.
- For scientific notation, the next node of `{E/e}` must be `+`, `-` or a number.
- `array` elements are not separated by `,`.
- `object` elements are not separated by `,`.
- No `:` after the key of `object`.
- `object` has `:` after the key but is missing the value.
- The key of `object` is not a string.

In addition to the conditions explicitly mentioned above, other errors may also trigger an "error rendering". There may also be errors outside the scope of the formatting check that do not trigger "error rendering". However, they may **lead to missing json content**.

Any other syntax errors will not trigger a rendering error.
It is recommended that you do not rely too much on `JSONPreview` format checking, and use it to preview correctly formatted json whenever possible.

### Link

The *1.2.0* version adds rendering of links (`.link`). While rendering, `JSONPreview` performs a limited **de-escaping** operation.
The *1.2.0* version adds rendering of links. While rendering, `JSONPreview` performs a limited **de-escaping** operation.

The de-escaping operations supported by different versions are as follows:

Expand Down
32 changes: 16 additions & 16 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,27 @@ previewView.preview(json, style: style)

### 渲染

对于渲染,`JSONPreview` 只进行**有限**的格式检查,包括:

> 以下所提到的 “上一个节点” 均不包括 `空格``\t` 以及 `\n`
- 所要预览的JSON必须以 `{``[` 开头。
- `:` 的上一个节点必须是 `.string`
- `,` 的上一个节点只能是 `.null``.link``.string``.number``.boolean``}` 以及 `]` 中的一个。
- `{` 必须存在上一个节点,同时上一个节点不能为 `{`
- `}` 必须与 `{` 成对出现。
- `[` 必须存在上一个节点,同时上一个节点不能为 `]`
- `]` 必须与 `[` 成对出现。
- `"` 必须成对出现。
- `"` 的上一个节点只能是 `{``[``,` 以及 `:` 中的一个。
- 针对 `null``true` 以及 `false` 的拼写检查。
对于渲染,`JSONPreview` 只进行**有限**的格式检查。

目前已知的会触发 “错误渲染” 的条件,包括:

- Value 非常规 JSON 类型。支持的类型包括 `object``array``number``bool``string` 以及 `null`
- 对于 `number` 格式的检查,例如科学计数法以及小数。
- 针对于 `true``false` 以及 `null` 的拼写检查。
- 针对科学计数法,`{E/e}` 的下一个节点必须是 `+``-` 或数字。
- `array` 元素之间没有使用 `,` 进行分隔。
- `object` 元素之间没有使用 `,` 进行分隔。
- `object` 的 key 后没有`:`
- `object` 的 key 后有`:`,但是缺失 value。
- `object` 的 key 不是字符串。

除了上述明确提到的条件,其他错误也可能触发“错误渲染”。另外还有可能有一些错误在格式检查的范围之外,这些错误不会触发“错误渲染”。但是可能**会导致 json 内容的缺失**

除此之外的语法错误均不会触发渲染错误
建议您不要过于依赖 `JSONPreview` 的格式检查功能,尽可能用于预览格式正确的 json

### 链接

*1.2.0* 版本增加了对链接(`.link`)的渲染功能。在渲染的同时,`JSONPreview` 会进行有限的**去转义**操作。
*1.2.0* 版本增加了对链接的渲染功能。在渲染的同时,`JSONPreview` 会进行有限的**去转义**操作。

不同版本支持的去转义操作如下:

Expand Down

0 comments on commit 952da41

Please sign in to comment.