generate json file

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
Ramzus
Participant
Posts: 4
Joined: Thu Jul 18, 2019 12:19 pm
Location: ste julie

generate json file

Post by Ramzus »

Hi everybody
I would like to generate a json file from oracle table,
the first step i did a job to generate a sequential file from oc
the second one, i tryed to compose a json file from sequetial file using Hiearchical Data stage, i prepared a shema json, the problem that my output(json file) still empty
based on ibm example i understood that schema json it could be the first record:

Code: Select all

{
	"product": [

	{ "NO_PROD": "10000",
       "NO_VERS_PROD": "32",
	  "CD_FAML_PROD": "voy",
	  "IND_TAXB": "1",
	  "IND_PLAN_OBLG": "0",
	  "IND_PREN_DIFF_ASSR_PRIN": "0" ,
	  "DT_DEBT_DISP": "2007-12-01",
	  "MTN_PRIM_MIN": "25,00" ,
	  "DT_CREA": "07-SEP-07 10.08.28.875 AM+0100",
	  "CD_UTIL_CREA": "superadmin",
	  "NOM_PROD_FR": "Assurance Voyage À la Carte",
	  "NOM_PROD_EN": "Individual Travel Insurance",
	  "NOM_PROD_ABRG_FR": "Assurance Voyage À la Carte",
	  "NOM_PROD_ABRG_EN": "Individual Travel Insurance",
	  "DT_FIN_DISP": "2007-12-01",
	  "DT_ENTR_VIGR": "2007-12-01",
	  "DT_FIN_DISP_RENV": "2007-12-01",
	  "CLAS": "",
	  "SOUS_CLAS": "",
	  "CD_MOD_RENV": "",
	  "DT_RENV": "",
	
	}
	] 
 }
Help please
Thank you
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome aboard.

Thanks for creating your own topic for this discussion. But we're going to keep it all here so I deleted your post on the end of this older JSON discussion which didn't really seem to have a direct bearing on what you are doing or needing help with. Of course, if the original poster wants to chime in here and help out, they are more than welcome to. :wink:

As part of trying to help with this, have you worked with JSON files before and just need some DataStage help with them or are they all new? Are you seeing any errors when your job runs? I'm just asking for a friend as I never have worked with them myself, I'm just hoping to get more information out there for whoever has and tries to help. Thanks.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

As Craig notes, more detail is needed...you need to map the "lists" from your imported JSON (in the Library Manager you can review it, or at the "root" part of the JSON composer).....this is a very difficult stage to learn initially..... browse also any/all of the xml compose or "build/write" XML posts that you can, since it uses the exact same techniques.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

for small, non nested, extremely simple markup files, I am often willing to just generate them directly without any parsing/thinking/schema/etc. Its faster, easier to code, etc but its no good if you need to change it a lot over time. Most of this stuff does not change over time though. Just a thought. Once it gets nested or large, you still need to know how to do it right!
Ramzus
Participant
Posts: 4
Joined: Thu Jul 18, 2019 12:19 pm
Location: ste julie

Post by Ramzus »

Thank yu Craig,
I have worked and i work with datastage but never with json, i'm seeing any errors, the json file is generated but is empty.
Thank you
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm assuming you meant to say "i'm not seeing any errors", yes?

As noted, it's not an easy stage to learn how to use. Experience with the XML equivalent Hierarchical stage would be helpful but I'm guessing that's something else you've not had a chance to work with yet either. Have you involved your official support provider? In your shoes that's what I would be doing along with the research that Ernie noted.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Ramzus
Participant
Posts: 4
Joined: Thu Jul 18, 2019 12:19 pm
Location: ste julie

Post by Ramzus »

UCDI wrote:for small, non nested, extremely simple markup files, I am often willing to just generate them directly without any parsing/thinking/schema/etc. Its faster, easier to code, etc but its no good if you need to change it a lot over time. Most of this stuff does not change over time though. Just a thought. Once it gets nested or large, you still need to know how to do it right!
Thank you UCDI
How you do it to generate directly, how you could choose json file in output?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You wouldn't be choosing anything other than a sequential file. UCDI meant a technique where you build everything in a transformer, all the strings and structures coded by hand so the resulting file looks like a JSON file should look. As noted, the technique is only good for "small, non-nested, extremely simple" files, is that what you have?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Ramzus
Participant
Posts: 4
Joined: Thu Jul 18, 2019 12:19 pm
Location: ste julie

Post by Ramzus »

chulett wrote:You wouldn't be choosing anything other than a sequential file. UCDI meant a technique where you build everything in a transformer, all the strings and structures coded by hand so the resulting file looks like a JSON file should look. As noted, the technique is only good for "small, non-nested, extremely simple" files, is that what you have?
I thought that i could generate my json file from my sequential file directly.
Example in my distributor table i have 10330 recors so i couldnt coding by hand. Like i explained in my first post, i tryed to use Composing JSON data by using the JSON Composer, i did my json schema, mapping every think running well but my json output file still empty :(
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

right, what I was saying is you can just craft the text you need for small xml/json etc files. Its easier and more efficient than parsing and scheming and whatnot so long as you are ok with having to fix it if the fields change. The markup generation stages are a big hammer and your problem may be a tiny fly.
Post Reply