2025/05/14

JSONとYAML

## Example 1:
This is a JSON object:
```
{
  "Image": {
      "Width":  800,
      "Height": 600,
      "Title":  "View from 15th Floor",
      "Thumbnail": {
          "Url":    "http://www.example.com/image/481989943",
          "Height": 125,
          "Width":  100
      },
      "Animated" : false,
      "IDs": [116, 943, 234, 38793]
    }
}
```
## Example 2:
This is a JSON array containing two objects:
```
[
  {
     "precision": "zip",
     "Latitude":  37.7668,
     "Longitude": -122.3959,
     "Address":   "",
     "City":      "SAN FRANCISCO",
     "State":     "CA",
     "Zip":       "94107",
     "Country":   "US"
  },
  {
     "precision": "zip",
     "Latitude":  37.371991,
     "Longitude": -122.026020,
     "Address":   "",
     "City":      "SUNNYVALE",
     "State":     "CA",
     "Zip":       "94085",
     "Country":   "US"
  }
]
```
## Example 3:
YAML representation of example 1:
```
Image:
  Width: 800
  Height: 600
  Title: View from 15th Floor
  Thumbnail:
    Url: http://www.example.com/image/481989943
    Height: 125
    Width: 100
  Animated: false
  IDs:
    - 116
    - 943
    - 234
    - 38793

```
## Example 4:
YAML representation of example 2:
```
- precision: zip
  Latitude: 37.7668
  Longitude: -122.3959
  Address: ''
  City: SAN FRANCISCO
  State: CA
  Zip: '94107'
  Country: US
- precision: zip
  Latitude: 37.371991
  Longitude: -122.02602
  Address: ''
  City: SUNNYVALE
  State: CA
  Zip: '94085'
  Country: US
```
* [JSONの仕様(RFC8259)](https://tex2e.github.io/rfc-translater/html/rfc8259.html)
* [YAML(YAML Ain’t Markup Language)の仕様](https://yaml.org/spec/1.2.2/)

0 件のコメント:

コメントを投稿

人気の投稿