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.

[ODC]Record/ListをJSONSerializeして結果を観察する

Posted at

ODCで、CSVUtilのExportRecordList2CSV Actionのように、任意のListをCSVに変換したい。
JSONSerializeしたJSONをCSVに変換する方法の検討の一環として、JSONSerializeの出力構造を確認してみた。

同じ問題について、CLient Action内のJavaScript要素内でできないかと思って、調査してみた(JavaScript要素にObject型として渡した値の詳細を確認する (主に基本データ型))が、筋がよくなさそうなので方向転換。

確認方法

Structure/Entity/Record/List型の変数を用意する。
変数をJSONSerializeし、変数の型と、Serializeした結果のJSONを比較してみる。

JSONSerializeのSerialize Default Values=Yesに設定しておく(そうしないと、Default Valueを設定しておくと項目が出力されなくなるので)。

確認結果

結果は以下の表にまとめた。JSONSerializeする場所がClient ActionのときとServer Actionのときで違いが見られなかったので、表にはClient/Serverの区別は載せていない。

データ構造列:変数の型を展開したものをスクリーンショット
結果(eval):JSONSerializeした結果のJSONを、JavaScriptオブジェクトに変換して、その構造をスクリーンショット(ブラウザの開発者ツールを開き、コンソールタブでevalにJSONに渡す)

データの種類 データ構造 結果(eval)
Record image.png image.png
Structure:シンプル image.png image.png
Structure:子Structure有 image.png image.png
Structure:External Logicに定義 image.png image.png
Structure:Listを要素に持つ image.png image.png
Structure:リスト image.png image.png
Entity:単独・1レコード image.png image.png
Entity:単独・リスト image.png image.png
Entity:ジョイン・1レコード image.png image.png
Entity:ジョイン・リスト image.png image.png
Entity:ジョイン+計算列追加・1レコード image.png image.png
Entity:ジョイン+計算列追・リスト image.png image.png

確認結果まとめ

JSONSerializeした結果は、想定通り(変数の型地そのまま)なのであまりコメントすることがないが

  • Entity/Structure/Record1つに対応する部分は、それぞれのAttribute名がそのままJavaScriptオブジェクトのプロパティ名になる
  • 渡した変数の子要素が別のEntity/Structureを持っている場合は、子要素名がそのままJavaScriptのプロパティ名にマッピングされる(例:「Entity:ジョイン・1レコード」の場合、Aggregateガ子要素としてとしてSample_Office EntityとSample_OfficeReviews Entityがあるが、これがJSON上では同名の親オブジェクトにマッピングされる)
  • Listは配列にマッピングされる
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?