0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

2015-07-04 C++ Builder XE4 > JSONファイル処理 > ParseJSONValue() / Get(idx) / JsonString-> / JsonValue->

Last updated at Posted at 2015-07-04

備考

(2019-05-21)

C++ Builder 10.2Tokyoでは下記の実装はSize()とGet()について古いと認識される。

実装

動作確認
C++ Builder XE4

以下の山本隆さんの記事が参考になる。
http://www.gesource.jp/weblog/?p=4567

# include <DBXJSON.hpp> // for JSON

void __fastcall TForm1::Button1Click(TObject *Sender)
{
	String jsonText = L"{ \"name\": \"Caroline Charonplop Kyary Pamyu Pamyu\", \"age\": 22 }";
	TJSONObject *jsonObj = dynamic_cast<TJSONObject*>(TJSONObject::ParseJSONValue(jsonText));

	String item, value;
	TJSONPair *pair;
	for(int idx=0; idx<jsonObj->Size(); idx++) {
		pair = jsonObj->Get(idx);
		item = pair->JsonString->Value();
		value = pair->JsonValue->Value();
        ShowMessage(L"item=" + item + L", value=" + value);
	}

	jsonObj->Free();
}

関連してこちらも参考になる。
http://www.gesource.jp/weblog/?tag=json

ParseJSONValue()は失敗する時がある
http://qiita.com/7of9/items/a923ffb936ea44b9536d

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?