JSON Composer:Prob in loading array with multiple objects

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
yammanur.dwhcareer
Participant
Posts: 7
Joined: Sun Apr 10, 2011 11:30 am
Location: Delhi

JSON Composer:Prob in loading array with multiple objects

Post by yammanur.dwhcareer »

I'm trying to compose a JSON file using the input data coming from Netezza Database. In the output JSON file I've to put some of the fields inside an array into two different objects.

Input Fields: (I just mentioned the fields which should insert into an array)
PROD_CATG_CODE_PRE_1
RPT_BRAND_GROUP_PRE_1
RPT_BRAND_SUBGROUP_PRE_1
RPT_BRAND_CODE_PRE_1
OM_BRAND_PRE_1
OM_BRAND_CODE_PRE_1
PROD_CATG_CODE_PRE_2
RPT_BRAND_GROUP_PRE_2
RPT_BRAND_SUBGROUP_PRE_2
RPT_BRAND_CODE_PRE_2
OM_BRAND_PRE_2
OM_BRAND_CODE_PRE_2

Schema file according to the requirement:

"PRE": [
{
"PROD_CATG_CODE": "SW/WASXP",
"RPT_BRAND_GROUP": "SWG",
"RPT_BRAND_SUBGROUP": "SW Cloud Solutions",
"RPT_BRAND_CODE": "AIM",
"OM_BRAND": "WebSphere - Open",
"OM_BRAND_CODE": "OADS"
},
{
"PROD_CATG_CODE": "TIV/TWS",
"RPT_BRAND_GROUP": "SWG",
"RPT_BRAND_SUBGROUP": "SW Cloud Solutions",
"RPT_BRAND_CODE": "Cloud & SI",
"OM_BRAND": "Tivoli Automation",
"OM_BRAND_CODE": "TVPA"
}
]

In the above schema file the first part {} is for PRE_1 elements and the second object is for PRE_2 elements.When I try to load the above schema in the schema library manager
the assembly editor is merging the data objects inside the array and showing only one single object like below.
[PRE]
--Object Value
PROD_CATG_CODE
RPT_BRAND_GROUP
RPT_BRAND_SUBGROUP
RPT_BRAND_CODE
OM_BRAND
OM_BRAND_CODE

Due to that I'm not able to map the other 6 columns to the output file.
Please suggest me a solution to map both PRE_1 and PRE_2 elements into the output file. I'm using Datastage 9.1 version

:idea: :idea: :idea: :idea:
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

DataStage is correct. In your json sample you don't have two groups here --- you have two "instances" of a single group, in an array. There is nothing structurally that is separating yor "pre 1" from "pre 2". They are just instances.

If your data is coming in as one row, two groups, pivot it outsode of the stage so that it is 2 rows, same column names. Each "pair" of rows then corresponding to your two "groups". Then they will get layed out in the array as you expect.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply