What to check if modified configuration files or API requests (JSON format) are not recognized correctly
Answer¶
Please check the JSON syntax.
Check The Description Rules¶
| Things to check | Incorrect example | Correct example |
|---|---|---|
| Check whether the {} (curly brackets) are consistent | {"key": "value" | {'key': "value"} |
| Check whether they are enclosed in single quotation marks | {'key': "value"} | {"key": "value"} |
| Check whether they are separated by semicolons | {'key'; "value"} | {"key": "value"} |
| Check whether full-width spaces are included | {"key": "value" } | {"key": "value" } |
| Check whether a comma (,) is used as a separator | {"key1": "value1" "key2": "value2" } | {"key1": "value1", "key2": "value2" } |
Check The Type to be Set¶
No errors will be detected as JSON syntax, but if you set a value of a different type, the same result as a syntax error will be returned.
| Type | Incorrect example | Correct example |
|---|---|---|
| Numerical value | "NumA": "0" | "NumA": 0 |
| Character | "ClassA": 3 | "ClassA": "3" |
| Boolean value | "CheckA": "true" | "CheckA": true |
| Date | "DateA": 2019/01/01 | "DateA": "2019/01/01" |
Escaping Special Symbols¶
| Escape notation | Original character | Description |
|---|---|---|
\" | " | Double quotation mark |
\\ | \ | Backslash |
\/ | / | Forward slash |
\n | Line break | |
\t | Tab |
When specifying a URL or path, escape processing is required as follows.
※The display of the Yen symbol (¥) and backslash will vary depending on the environment.
Syntax Check¶
If you search for a JSON syntax checker on a search site, you will find many services that will detect errors in the content of the JSON statement you created, so it is useful to use them.