Skip to main content
Question

Need some help with ingesting


Forum|alt.badge.img
  • Problem Solver
  • 112 replies

This is my JSON

{
    "projectNumber": "123456",
    "name": "TX",
    "addendumValues": {

        "addendumGroups": [
            {
                "addendumGroupName": "G1",
                "rows": [
                    {
                        "columns": {
                            "revnr_G1": [
                                "Rev.1"
                            ],
                            "date_G1": [
                                "2023-06-21T00:00:00.0000000"
                            ]
                        }
                    }
                ]
            },

			{
                "addendumGroupName": "G2",
                "rows": [
                    {
                        "columns": {
                            "revnr_G2": [
                                "Rev.1"
                            ],
                            "date_G2": [
                                "2023-06-21T00:00:00.0000000"
                            ]
                        }
                    },

					 {
                        "columns": {
                            "revnr_G2": [
                                "Rev.2"
                            ],
                            "date_G2": [
                                "2023-07-21T00:00:00.0000000"
                            ]
                        }
                    },

				 {
                        "columns": {
                            "revnr_G2": [
                                "Rev.3"
                            ],
                            "date_G2": [
                                "2023-08-21T00:00:00.0000000"
                            ]
                        }
                    }	
                ]
            }



		]
	}
}

xpath: /json/addendumGroups has multiple addendumGroupName, here i present only two.
I am trying to extract values for revnr_G1, date_G1, revnr_G2 and date_G2.

The code below only shows revnr_G1 and date_G1.
I am wondering why not revnr_G2 and date_G2 (please look away from case sensitivty) 

<api:info title="addendumGroups" desc="Generated schema file for TimeXtender." xmlns:other="http://apiscript.com/ns?v1">
    <!-- Attributes for the main JSON structure -->                                />
    <attr name="projectNumber"     				xs:type="string" readonly="false"              other:xPath="/json/projectNumber"                                />

    <!-- Attributes for rows and columns -->
	<attr name="columns:revnr_g1"      xs:type="string" readonly="false"            other:xPath="/json/addendumValues/addendumGroups/rows/columns/revnr_g1" />
    <attr name="columns:date_g1"   					xs:type="string" readonly="false"            other:xPath="/json/addendumValues/addendumGroups/rows/columns/date_g1" />

	<attr name="columns:revnr_g2"      xs:type="string" readonly="false"            other:xPath="/json/addendumValues/addendumGroups/rows/columns/revnr_g2" />
    <attr name="columns:date_g2"   					xs:type="string" readonly="false"            other:xPath="/json/addendumValues/addendumGroups/rows/columns/date_g2" />

</api:info>

I have also tried something like this, which gave me nothing:
 

<attr name="revnr_G1" xs:type="string"  readonly="false" other:xPath="/json/addendumGroups[addendumGroupName='G1']/rows/columns/revnr_G1" />
    <attr name="date_G1"           xs:type="string"  readonly="false" other:xPath="/json/addendumGroups[addendumGroupName='G1']/rows/columns/date_G1" />


<attr name="revnr_G2" xs:type="string"  readonly="false" other:xPath="/json/addendumGroups[addendumGroupName='G2']/rows/columns/revnr_G2" />
    <attr name="date_G2"           xs:type="string"  readonly="false" other:xPath="/json/addendumGroups[addendumGroupName='G2']/rows/columns/date_G2 />

Also some times a group name, for example "addendumGroupName": "G2", contains multiple columns. How to i reterive all ?

10 replies

Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1017 replies
  • February 10, 2025

Hi ​@aftabp 

It is not a great design for a setup of a RSD file, but you can get the data.

I made a file that gets it and the right data types. You have to remove the txt part of the file names of course.

All the addendumgroups has a named field, so it will continue to increase until you have no more.

If it had no naming it would look better. If you can’t control this you will have to use a query to merge them.

 

 


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • February 10, 2025

Dear ​@Thomas Lind ,
Thankyou for the reply. 
I managed the code that you have sendt. The problem however arrived where revnr_G2 comes up multiple times. 
With youe code, the marked values are not reterived 

 

 


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • March 5, 2025

Moving foward with this issue,

I am attaching the whole JSON file this time, and also the RSD file

I have tried different ways to get all addendumGroupNames and the assosiated values in rows but have but couldnt get it.

With this line, i can only get the first value in addendumGroupNames (line 418)

    <attr name="addendumGroups"                             xs:type="string" readonly="false"         other:xPath="/json/addendumValues/addendumGroups/addendumGroupName" />


 

 


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • March 5, 2025

This is absurd.
When i use a single response file, like the one above, i get the desired result. 
However, in nested statement i dont get anything from rows.
This works and i get all the addendumGroupNames and values that are for columns

 

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
  <api:info title="addendumGroups" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
    <!-- You can modify the name, type, and column size here. -->
    <attr name="addendumGroupName"  			xs:type="string" readonly="false"              other:xPath="/json/addendumValues/addendumGroups/addendumGroupName" />
    <attr name="columns"            			xs:type="string" readonly="false"              other:xPath="/json/addendumValues/addendumGroups/rows/columns"      />
  </api:info>

  <api:set attr="DataModel" value="FLATTENEDDOCUMENTS" />
  <api:set attr="URI" value="C:\\temp\\response.json" />

  <api:set attr="JSONPath" value="$.addendumValues.addendumGroups;$.addendumValues.addendumGroups.rows" />


</api:script>

For this, i get all the addendumGroupNames but values that are for columns are empty

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <!-- Schema information and column definitions for TimeXtender integration -->
  <api:info title="addendumGroups" desc="Generated schema file for TimeXtender." xmlns:other="http://apiscript.com/ns?v1">
    <!-- Attributes for the main JSON structure -->
    <attr name="projectRec" 		xs:type="string" readonly="false" 			   other:xPath="DUMMY" />
	<attr name="addendumGroupName"  xs:type="string" readonly="false"              other:xPath="/json/addendumValues/addendumGroups/addendumGroupName" />
    <attr name="columns"            xs:type="string" readonly="false"              other:xPath="/json/addendumValues/addendumGroups/rows/columns[0]"      />
  </api:info>

  <!-- Base URL and settings -->
  <api:set attr="urlbase" value="https://my.api.endpoint" />

  <api:set attr="touchIn.DataModel" 		value="FLATTENEDDOCUMENTS" />
  <api:set attr="touchIn.EnablePaging" 		value="TRUE" />
  <api:set attr="touchIn.JSONPath" 			value="$." />
  <api:set attr="touchIn.URI" 				value="[urlbase]/api/Project/GetProjects" />
  <api:set attr="touchIn.ElementMapPath#" 	value="/json/projectRec" />
  <api:set attr="touchIn.ElementMapName#" 	value="file_id" />

  <api:set attr="detailsIn.DataModel" 		value="FLATTENEDDOCUMENTS" />
  <api:set attr="detailsIn.EnablePaging" value="TRUE" />
  <api:set attr="detailsIn.JSONPath" 		value="$.addendumValues.addendumGroups;$.addendumValues.addendumGroups.rows" />

  <api:set attr="detailsIn.URITemplate" value="[urlbase]/api/Project/GetProjectByRec/{file_id}" />

  <!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
	<api:script method="GET">	
		<api:set attr="touchIn.URI" value="[touchIn.URI]" />
		<api:call op="jsonproviderGet" in="touchIn" out="touchOut">

 <!-- Clean projectRec -->
      <api:set attr="touchin.cleanedProjectRec" 
               value="[touchOut.file_id | trim()]" />

          <!-- Replace projectNumber in URI -->
          <api:set attr="detailsIn.URI" 
                   value="[detailsIn.URITemplate | replace('{file_id}', [touchin.cleanedProjectRec])]" />
			<api:call op="jsonproviderGet" in="detailsIn" out="detailsOut">

		<api:set attr="out.projectRec"						value="[touchOut.file_id | allownull()]"/>
		<api:set attr="out.addendumGroupName" 				value="[detailsOut.addendumGroupName | allownull()]" />
		<api:set attr="out.columns" 						value="[detailsOut.columns | allownull()]" />
        <api:push item="out" />
      </api:call>
    </api:call>
  </api:script>

</api:script>


 


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1017 replies
  • March 6, 2025

Hi ​@aftabp 

In the addendumValues/addendumGroups/rows/columns[0] path, what sort of data is it supposed to return? 

Can you share a mock json file with this setup? I would like to try it in the new JSON provider we made.


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • March 7, 2025

@Thomas Lind 
I have tried both addendumValues/addendumGroups/rows/columns[0] and addendumValues/addendumGroups/rows[0] but was unable to reterive the desired results. 
You can use response_json.txt. I dont have any real values in there.

As metioned, when i try the response_json (see the attached file from a day ago) i get the values in column

When i try nested, i dont get values in column.
I have stripped down the nested_rsd to include only 3 fields.

 


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • March 11, 2025

@Thomas Lind , any suggestions? 
The strange part is that the text that should appear in columns, i can see it in log-file.
Why isnt it comming up in TX table !


Forum|alt.badge.img
  • Author
  • Problem Solver
  • 112 replies
  • March 11, 2025

Somehow, it just worked.
Only thing i did is to delete the RSD i am working on and create RSD from scratch.


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1017 replies
  • March 11, 2025

Hi ​@aftabp 

Each column sub section contains some individual fields. You can’t make it get those without splitting them all out.

I made a file using FlattenedDocuments you can see what I mean in that as it generated a field for each unique field type there is. I also added a [0] for all fields to get the actual value out of it.


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1017 replies
  • March 11, 2025

I did not see your newest message before replying to this. Can you send this or did you send it already?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings