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 5 years have passed since last update.

c++ builder > JSON > ファイル読込み > キー指定で値読込み > pairObj = jsonObj->Get(L"name");

0
Last updated at Posted at 2015-07-24

http://qiita.com/7of9/items/41d8b9adb06a6e930058
にて書き出したファイルからの読み込み

"name"`というキーの値を取得する。

# include <DBXJSON.hpp> // for JSON
# include <memory> // for unique_ptr

...

	std::unique_ptr<TStringList> slread(new TStringList);
	slread->LoadFromFile(L"test.json");

	TJSONObject *jsonObj = new TJSONObject();
	String jsonKey, jsonValue;
	TJSONPair *pairObj;

	for(int li=0; li < slread->Count; li++) { // file line index
		String jsonText = slread->Strings[li];
		jsonObj = dynamic_cast<TJSONObject*>(TJSONObject::ParseJSONValue(jsonText));

		pairObj = jsonObj->Get(L"name");
		if (pairObj != NULL) {
			jsonValue = pairObj->JsonValue->Value();
			ShowMessage(L"name:" + jsonValue);
		}
	}
	jsonObj->Free();

こちらが参考になった。
http://www.gesource.jp/weblog/?p=4567

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?