How to transform multi level xml message to multi level JSON Output and generate a file output

Four Stars

How to transform multi level xml message to multi level JSON Output and generate a file output

I need to create a map between multi level xml input file and transform using map source xml format to json format and generate a multi level output json file as mentioned below.

 

Sample input : 

<Employees>
   <Employee>
      <ProjectDetails>
           <ProjectName>ABC</ProjectName>
           <ProjectLocation>Bangalore</ProjectLocation>
       </ProjectDetails>
       <EmployeeDetails>
           <EmpID>EXP001</EmpID>
           <EmpName>Kumar</EmpName>
       </EmployeeDetails>
   </Employee>

   <Employee>
      <ProjectDetails>
        <ProjectName>XYZ</ProjectName>
        <ProjectLocation>Bangalore</ProjectLocation>
      </ProjectDetails>
      <EmployeeDetails>
        <EmpID>EXP0012</EmpID>
        <EmpName>Shanmugam</EmpName>
      </EmployeeDetails>
   </Employee>
</Employees>

Sample JSON output expected : 
{
"employees": {
    "employee":

    [

      {
        "firstName": "John",
        "EmpID": "Doe",
        "ProjectDetails":

        {
           "ProjectName": "ABC",
           "ProjectLocation" : "Bangalore"
        }
      },
     {
        "firstName": "John",
         "EmpID": "Doe",
          "ProjectDetails":

          {
             "ProjectName": "ABC",
             "ProjectLocation" : "Bangalore"
          }
      }
    ]
  }
}

 

I am finding it difficult to generate output in target multi level JSON format as tFileOutputJSON node is generating flat JSON structure only.

 

Any suggession on steps to generate multi level JSON file is much appreciated

Four Stars

Re: How to transform multi level xml message to multi level JSON Output and generate a file output

I managed to get it working using approach mentioned below.

 

tFileInputJson --> tWriteXMLField --> tFileOutputRaw

 

Note : I am using tFileOutputRaw instead of tFileOutputXML as i am already parsing the data in tWriteJsonField.

 

Any comment of better practice to improve my solution and maping the same is much appreciated.