問題 ccnp-350-401-topic-1-question-920・第2版

問題

JSONとして正しい構文はどれか。

  1. A 
    ["Lodging": [
     {
     "type":hotel,
     "location":B01
     "contact":446-301-12847
     }
     ]
    ]
    

    候補A

  2. B 
    {
     "truck": [
     {
     "type": "Ford",
     "color": "red",
     "year": "1998"
     }
     ]
    }
    

    候補B

  3. C 
    ["car":{
     "type": "Ford",
     "color": "red",
     "year": "1998",
     }
    ]
    

    候補C

  4. D 
    [
     "subject":{
     "title": "Art History"
     "listing": "elective"
     "session": "Spring"
     }
    ]
    

    候補D

正解:B

理由

キーと文字列値を二重引用符で囲み、オブジェクトは波括弧、配列は角括弧を対応させる。メンバーをカンマで区切り、末尾へ余分なカンマを置かない。

選択肢ごとの説明

A.
["Lodging": [
 {
 "type":hotel,
 "location":B01
 "contact":446-301-12847
 }
 ]
]

候補A

配列へLodgingというキーを直接置いている。hotelやB01が引用符で囲まれず、区切りにも不足がある。

B.
{
 "truck": [
 {
 "type": "Ford",
 "color": "red",
 "year": "1998"
 }
 ]
}

候補B

truckの値は配列で、内部のオブジェクトに正しいキーと文字列値、区切り、括弧がある。

C.
["car":{
 "type": "Ford",
 "color": "red",
 "year": "1998",
 }
]

候補C

配列へcarというキーを直接置き、最後のメンバーにも余分なカンマがある。

D.
[
 "subject":{
 "title": "Art History"
 "listing": "elective"
 "session": "Spring"
 }
]

候補D

メンバー間のカンマがない。配列へsubjectのキーとオブジェクトを直接置く構造も不正である。

お問い合わせ

演習する →