Skip to content

Commit

Permalink
chore(docs): improve JSON.rawJSON() example snippet (#36598)
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle authored Oct 31, 2024
1 parent bdf8842 commit 0e8730e
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ This may not be desirable, because the receiver of this string may handle Unicod
```js
const rawJSON = JSON.rawJSON('"\\ud83d\\ude04"');
const objStr = JSON.stringify({ value: rawJSON });
console.log(objStr); // {"value":"\ud83d\ude04"}
console.log(JSON.parse(objStr).value); // 😄
```

Note that the double backslashes in the `rawJSON` actually represents a single slash character, so the JSON text looks like:

```json-nolint
{"value":"\ud83d\ude04"}
```
Note that the double backslashes in the `rawJSON` actually represents a single slash character.

## Specifications

Expand Down

0 comments on commit 0e8730e

Please sign in to comment.