JSON
JavaScript Object Notation
構造化されたData データを表現可能データ形式
CSVとXMLの中間
用途
IoT Internet of Thingsのデータ形式に採用されてる
CSVから移動した
RESTful APIの返り値でよく使う。
JSON、RESTful APIのだめな点を補う技術
OpenAPI,GraphQL
hr.icon
JSON返すAPI
無料
Google Apps Script GAS
JSONPlaceholder - Fake online REST API for developers
例 users https://jsonplaceholder.typicode.com/users
10人分のデータあり
Google Chrome拡張
JSONPlaceholder - Fake online REST API for developers
Javascript処理
JSON.stringify(obj)
JavaScriptオブジェクトをJSON文字列に変更
使用例
JSONファイルのデータをハッシュ関数 hash functionに渡す時
形統一
JSON.parse(String)
JSON形式の文字列をJSONオブジェクトに変換
code:json.js
const fruit ={
place:'yamanashi',
cost:100,
name:'apple'
}
const jsonStr = JSON.stringify(fruit)
//{"place":'yamanashi',"cost":100,"name":'apple'}
console.log(JSON.parse(jsonStr))//fruit{}
参考
Introduciing JSON JSON.org
JSON:API — A specification for building APIs in JSON
The JSON Data Interchange Format