0
0

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 1 year has passed since last update.

C++でJSON <Visual Studio 2022>

Posted at

Visual Studio C++でJSONを使うコード。
色々ググったけども、ストレートな記事が少なかったのでここにメモ。
JSONのデータ構造は予め把握しておく必要あり。

json_sample.cpp
#include <winrt/Windows.Data.Json.h>

using namespace Windows::Data::Json;

bool getConfigData(std::wstring json_string, Config *config) {
    //JSON文字列をパース
    JsonObject json_object = JsonObject::Parse(json_string);

    //tokenキーの値を文字列として取得
    //config->tokenは予め用意したクラス変数
    config->token = json_object.GetNamedString(L"token");
}

参考記事

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?