Customer Portal

Generate JSON file from CCD

Comments 3

  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hi Rajesh,
    let me break this down into 2 separate issues: reading the CCD file and writing into a JSON file:

    1. I understood that the CCD file is basically a file containing some XML code. We have 3 different components that can read XML code: XMLExtract, XMLReader and XMLPathReader. Since you are new to CloverETL I would suggest taking advantage of the XMLExtract component as it provides a user friendly GUI for mapping the XML tags and attributes to the output metadata. More information on how to use the XMLExtract component can be found here.

    2. As for writing your data into JSON, I would recommend the JSONWriter component. The Help document can be found and reviewed here.

    As an example graph, I suggest reviewing the inbuilt examples in the CloverETL Designer (they are available since the 4.6 version of CloverETL Designer). If you launch the Designer and navigate to Help > CloverETL Examples, it will open up a list of graphs where you would want to review these 2 graphs in the Basic reading & writing section: “XML Files” and “JSON Files”.
    Regards,
  • Avatar
    rajesh
    0
    Comment actions Permalink
    Thank you so much for your reply Vladimir.

    This is will really helped me i went through all videos and prepared the same in local system.

    however, If i use the XMLExtract and JSON Writer i have to mapping so many things like i need to select individual checkboxs. do we have any functionality to check whole nodes in one time. because my CCD consists a lot of nodes and attributes. i think again i need to convert that XML to XSD to generate that into JSON? do we have any shortcut to implement this.

    your inputs will really helps me.

    Thanks,
    Raj
  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hi Rajesh,
    there is indeed an easier way in case you simply need to transform the XML code to JSON as is. It can be achieved by performing the following steps:

    • Use the XMLExtract component to read the entire CCD file content into a single field.

    • Push this field through a Reformat component and take advantage of the xml2json CTL function in order to transform the XML code to JSON code.

    • Write the JSON code into an output file by using the JSONWriter component.

    Note #1:
    There are multiple ways how to read the entire file content into a single field, for example by using FlatFileReader).
    Note #2:
    If you intend to utilize XMLExtract, you will have to perform the mapping in the following way:

    • Assuming the input file is selected, click on the Mapping edit button.

    • In the pop-up window, click on the ‘Generate tree structure’ button. This will generate the .XSD file and you will be able to see the tree structure.

    • Select the checkbox of the root element and define the output port (port 0) and the output metadata (consisting of a single string field).

    • Drag [element with children – element, text and subelements] from the Input grid and drop it on the single field in the Output grid.

    Respectfully,

Please sign in to leave a comment.