1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JSON.stringify()について解説してみた──オブジェクトを文字列に変換する基本

Last updated at Posted at 2025-10-24

はじめに

Reactの開発中に、コンポーネントの中で
key={JSON.stringify(filters)}を使う機会があったので、改めてまとめたいと思います。

JSON.stringify()とは?

JSON.stringify()は、JavaScriptの オブジェクトや配列を文字列に変換する 関数です。

基本の使い方

const user = { name: "carlos", age: 20 };
const json = JSON.stringify(user);

console.log(json);
// → '{"name":"carlos","age":20}'

オブジェクトが JSON形式の文字列 に変わります。

まとめ

JSON.stringify()は「オブジェクトを安全に文字列として扱うための関数」。
JavaScriptでは、データをそのまま保存したり送ったりすることができない場合が多く、JSON.stringify()を使って文字列に変換することで、さまざまな場面で活用できます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?