JSON文字列をDictionary構造体へ変換する関数です。 オブジェクトのネストや配列、UTF-8文字列にも対応しています。

概略

JSON形式の文字列をDictionary構造体にセットします

シンボル

Deserialize

JSONをDictionaryに変換

Deserialize関数のファンクション
入力
In
BYTE[65535]
JSON文字列
入出力
dic
SimpleJSON\sDictionary
ディクショナリ

変換例

例1

JSON

Directory
KeyValue
squadName "Super hero squad"
homeTown "Metro City"
formed 2016
secretBase "Super tower"
active true
members [{$"name$":$"MoleculeMan$", $"age$":29, $"secretIdentity$":$"DanJukes$", $"powers$":[$"Radiationresistance$", $"Turningtiny$", $"Radiationblast$"]}, {$"name$":$"MadameUppercut$", $"age$":39, $"secretIdentity$":$"JaneWilson$", $"powers$":[$"Milliontonnepnch$", $"Damageresistance$", $"Superhumanreflexes$"]}, {$"name$":$"EternalFlame$", $"age$":1000000, $"secretIdentity$":$"Unknown$", $"powers$":[$"Immortality$", $"HeatImmunity$", $"Inferno$", $"Teleportation$", $"Interdimensionaltravel$"]}]

例2(objectのネストがあるJSON)

JSON

Directory
Key Value
image.width 800
image.height 600
image.Title "View from 15th Floor"
image.Thumbnail.Url "http://www.example.com"
image.Thumbnail.Height 125
image.Thumbnail.Width 100
image.IDs [116,943, 234, 38793]
image2.width 100
image2.height 200
image2.Title "View from 16th Floor"
image2.Thumbnail.Url "http://www.example.com"
image2.Thumbnail.Height 25
image2.Thumbnail.Width 10
image2.IDs [16,93, 24, 3793]

例3(漢字の入ったJSON)

JSON

Directory
Key Value
image.幅 800
image.高さ 600
image.Title "15階からの景観"
image.Thumbnail.Url "http://www.example.com"
image.Thumbnail.Height 125
image.Thumbnail.Width 100
image.IDs [116,943, 234, 38793]

よくある質問

ネストしたJSONは変換できますか?

できます。オブジェクトのネストは「image.Thumbnail.Url」のようなキーへ展開されます。

UTF-8の日本語は扱えますか?

扱えます。漢字を含むJSON文字列もDictionaryへ変換可能です。

関連ページ

この記事へのコメント