Viewing JSON Services in RAD Studio Data Explorer

How to view JSON services in RAD Studio Data Explorer using the CData ODBC Driver for JSON.

最終更新日:2023-06-12

Embarcadero RAD Studio provides a development environment for Delphi and C++Builder applications. With the CData ODBC Driver for JSON, you gain access to live JSON services within RAD Studio, abstracting the data into tables, views, and stored procedures that can be used to both retrieve and update JSON services. This article will walk through connecting to JSON using the Data Explorer.

Configure a Connection to JSON

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.

データソースへの認証については、ヘルプドキュメントの「はじめに」を参照してください。CData 製品は、JSON API を双方向データベーステーブルとして、JSON ファイルを読み取り専用ビュー(ローカル ファイル、一般的なクラウドサービスに保存されているファイル、FTP サーバー)としてモデル化します。HTTP Basic、Digest、NTLM、OAuth、FTP などの主要な認証スキームがサポートされています。詳細はヘルプドキュメントの「はじめに」を参照してください。

URI を設定して認証値を入力したら、DataModel を設定してデータ表現とデータ構造をより厳密に一致させます。

DataModel プロパティは、データをどのようにテーブルに表現するかを制御するプロパティで、次の基本設定を切り替えます。

  • Document(デフォルト):JSON データのトップレベルのドキュメントビューをモデル化します。CData 製品 は、ネストされたオブジェクト配列を集約されたJSON オブジェクトとして返します。
  • FlattenedDocuments:ネストされた配列オブジェクトと親オブジェクトを、単一テーブルに暗黙的に結合します。
  • Relational:階層データから個々の関連テーブルを返します。テーブルには、親ドキュメントにリンクする主キーと外部キーが含まれています。

リレーショナル表現の設定についての詳細は、ヘルプドキュメントの「JSON データのモデリング」を参照してください。また、以下の例で使用されているサンプルデータも確認できます。データには人や所有する車、それらの車に行われたさまざまなメンテナンスサービスのエントリが含まれています。

Amazon S3 内のJSON への接続

URI をバケット内のJSON ドキュメントに設定します。さらに、次のプロパティを設定して認証します。

  • AWSAccessKey:AWS アクセスキー(username)に設定。
  • AWSSecretKey:AWS シークレットキーに設定。

Box 内のJSON への接続

URI をJSON ファイルへのパスに設定します。Box へ認証するには、OAuth 認証標準を使います。 認証方法については、Box への接続 を参照してください。

Dropbox 内のJSON への接続

URI をJSON ファイルへのパスに設定します。Dropbox へ認証するには、OAuth 認証標準を使います。 認証方法については、Dropbox への接続 を参照してください。ユーザーアカウントまたはサービスアカウントで認証できます。ユーザーアカウントフローでは、以下の接続文字列で示すように、ユーザー資格情報の接続プロパティを設定する必要はありません。 URI=dropbox://folder1/file.json; InitiateOAuth=GETANDREFRESH; OAuthClientId=oauthclientid1; OAuthClientSecret=oauthcliensecret1; CallbackUrl=http://localhost:12345;

SharePoint Online SOAP 内のJSON への接続

URI をJSON ファイルを含むドキュメントライブラリに設定します。認証するには、User、Password、およびStorageBaseURL を設定します。

SharePoint Online REST 内のJSON への接続

URI をJSON ファイルを含むドキュメントライブラリに設定します。StorageBaseURL は任意です。指定しない場合、ドライバーはルートドライブで動作します。 認証するには、OAuth 認証標準を使用します。

FTP 内のJSON への接続

URI をJSON ファイルへのパスが付いたサーバーのアドレスに設定します。認証するには、User およびPassword を設定します。

Google Drive 内のJSON への接続

デスクトップアプリケーションからのGoogle への認証には、InitiateOAuth をGETANDREFRESH に設定して、接続してください。詳細はドキュメントの「Google Drive への接続」を参照してください。

Connecting to JSON Services Using Data Explorer

You can create a simple application for displaying JSON services by utilizing the CData FireDAC Components for JSON and a new VCL Forms Application:

  1. Open the Data Explorer in RAD Studio and expand FireDAC.
  2. Right-click the ODBC Data Source node in the Data Explorer.
  3. Click Add New Connection.
  4. Enter a name for the connection.
  5. In the FireDAC Connection Editor that appears, set the DataSource property to the name of the ODBC DSN for JSON.
  6. Back in the Data Explorer, expand the tables for the connection.
  7. Create a new VCL Forms application and drag a table (for example: people) onto the form.

  8. Select the peopleTable object on the form and set the Active property to true.
  9. Right-click on the object, bind visually, and link everything (*) to a new control (TStringGrid).

  10. Arrange the TStringGrid on the form and run the application to see the people data.

Related Articles

Below you can find other articles for using the CData ODBC Driver with RAD Studio, Delphi, and C++ Builder.

関連コンテンツ

トライアル・お問い合わせ

30日間無償トライアルで、CData のリアルタイムデータ連携をフルにお試しいただけます。記事や製品についてのご質問があればお気軽にお問い合わせください。