Skip to content

Commit

Permalink
2024/11/01 時点の英語版に基づき更新
Browse files Browse the repository at this point in the history
  • Loading branch information
mfuji09 committed Dec 18, 2024
1 parent 0609295 commit 09e2b11
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: JSON.rawJSON()
slug: Web/JavaScript/Reference/Global_Objects/JSON/rawJSON
l10n:
sourceCommit: e7fab5265b54dc9faeff7e8cf4972cc171ec856b
sourceCommit: 0e8730e1a9bdfaa1710530c47135f79cedc3e94b
---

{{JSRef}}
Expand Down Expand Up @@ -45,7 +45,7 @@ JSON.stringify({ value: 12345678901234567890 });

この値は元の数値と正確には等しくありません!これは JavaScript がすべての数値に浮動小数点数を使用しているため、すべての整数を正確に表すことができないからです。数値リテラル `12345678901234567890` 自体は、 JavaScript によって解釈されるときに、最も近い表現可能な数値に丸められます。

`JSON.rawJSON` がなければ、対応する JavaScript の数値が存在しないため、 `JSON.stringify``12345678901234567000` という数値リテラルを生成するように指示する方法はありません。生の JSON では、具体的な値を文字列化するように `JSON.stringify()` に直接指示することができます。
`JSON.rawJSON` がなければ、対応する JavaScript の数値が存在しないため、 `JSON.stringify``12345678901234567890` という数値リテラルを生成するように指示する方法はありません。生の JSON では、具体的な値を文字列化するように `JSON.stringify()` に直接指示することができます。

```js
const rawJSON = JSON.rawJSON("12345678901234567890");
Expand Down Expand Up @@ -114,14 +114,11 @@ console.log(JSON.stringify({ value: "\ud83d\ude04" })); // {"value":"😄"}
```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); // 😄
```

`rawJSON` の二重バックスラッシュは、実際には単一のバックスラッシュ文字を表しますので、 JSON テキストは次のようになることに注意してください。

```json-nolint
{"value":"\ud83d\ude04"}
```
`rawJSON` の二重バックスラッシュは、実際には単一のバックスラッシュ文字を表します。

## 仕様書

Expand Down

0 comments on commit 09e2b11

Please sign in to comment.