📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)

文字列「__FORCETOC__」を「{{#seo: |title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki |keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板 |description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This pag…
 
(同じ利用者による、間の2版が非表示)
113行目: 113行目:
<br>
<br>
==== 配列オブジェクトの場合 ====
==== 配列オブジェクトの場合 ====
<syntaxhighlight lang="json">
# Sample.json
{
    {
      "description": "SomeDescription",
      "message": "SomeMessage"
    },
    {
      "description": "Home",
      "message": "Welcome",
      "imp":["awesome","best","good"]
    }
}
</syntaxhighlight>
<br>
<syntaxhighlight lang="c++">
#include <QFile>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QString>
#include <QDebug>
void readJson()
{
    // Jsonファイルの読み込み
    QFile file("Sample.json");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "JSONファイルの読み込みに失敗しました" << filePath;
        return;
    }
    QByteArray jsonData = file.readAll();
    // ファイルを閉じる
    file.close();
    QJsonDocument document = QJsonDocument::fromJson(jsonData);
    if (!document.isArray()) {
      qDebug() << "JSONファイルに配列オブジェクトがありません";
      return;
    }
    QJsonArray jsonArray = document.array();
    foreach (const QJsonValue &value, jsonArray) {
      QJsonObject obj = value.toObject();
      QString desc    = obj["description"].toString();
      QString message = obj["message"].toString();
      // キーの値が配列の場合、配列を文字列に変換する
      QJsonArray impvalues = obj["imp"].toArray();
      // 配列から要素を指定して取得する場合
      QString impvalue1 = impvalues[1].toString();
      // ...略
    }
}
</syntaxhighlight>
<br><br>
<br><br>


386行目: 446行目:
<br><br>
<br><br>


{{#seo:
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux
|image=/resources/assets/MochiuLogo_Single_Blue.png
}}


__FORCETOC__
__FORCETOC__
[[カテゴリ:Qt]]
[[カテゴリ:Qt]]