Skip to main content

Hello,

I am creating a josn using the json Templater. In my setting i have a subtemplate that must to be an "object" and contain a lot off nested attributes that are "list".

In the situation where only 1 attribute is populated, the final result is good (Topology1record.jpg screenshot) but when I have more attributes populated the result is an array and not an object (Topology2records.jpg screenshot). I also attached the templater to show what I did.

My final result should be:

 

{

  "type" : "FeatureCollection",

  "features" : t

     {

 

        "id" : "rfs:7BBE13D625241D58",

        "properties" : {

 

           "topologyCharacteristics" : {

 

                 "isPaved" : >

                    {

                       "range" : {

                          "endOffset" : 1,

                          "startOffset" : 0

                       },

                       "value" : false

                    }

                 ],

 

                 "isFourWheelDrive" :  

                    {

                       "range" : {

                          "endOffset" : 1,

                          "startOffset" : 0

                       },

                       "value" : true

                    }

                 ]

             }

 

            }

              }

         ] 

   }

 

How can i resolve this problem.

 

Thanks to all

 

Max

Hello @geomax​ 

I tried to reproduce the issue using some dummy features but was unable to. Note that I did remove all sub templates except for TOPOLOGYCHARACTERISTIC and INTERSECTIONCATEGORY in the JSONTemplater. This produced the result as shown in Topology1record.jpg, which should be the result you require.

Are you able to share a small sample of your input data?


Hello @debbiatsafe​ ,

Thanks for your help.

Attached I created a test data for you. There are only 2 attributes that I am sure create the error.

Exactly, my output have to be equal to Topology1record.jpg also in case I have more attributes stored under "topologycharactheristic".

Using another jsontemplater I created the right schema but when I merge all data together I have the same situation. The object is converted in array.

 

Thanks

 

Max


Hello @geomax​ 

I tried to reproduce the issue using some dummy features but was unable to. Note that I did remove all sub templates except for TOPOLOGYCHARACTERISTIC and INTERSECTIONCATEGORY in the JSONTemplater. This produced the result as shown in Topology1record.jpg, which should be the result you require.

Are you able to share a small sample of your input data?

Hello @debbiatsafe​,

probably I resolved. The solution is to aggregate all record and attributes under the "topologycharactheristic" session. After that I used a Json templater and a json formatter to create the json as an object. at the end, i can connect these steps to the main Json templater to create the full json. My problem, now, is that using the aggregator the templater is not able to convert the string values in boolean or float in case are number and I have this message: JSONTemplater_5 (XMLTemplaterFactory): "xs:string": invalid value for cast/constructor: can not cast to "xs:float"

If I use the same json templater setting without the aggregator it works!

 

When I will resolve this error, I will post the right workflow.

 

Thanks

Max


Hello @debbiatsafe​,

probably I resolved. The solution is to aggregate all record and attributes under the "topologycharactheristic" session. After that I used a Json templater and a json formatter to create the json as an object. at the end, i can connect these steps to the main Json templater to create the full json. My problem, now, is that using the aggregator the templater is not able to convert the string values in boolean or float in case are number and I have this message: JSONTemplater_5 (XMLTemplaterFactory): "xs:string": invalid value for cast/constructor: can not cast to "xs:float"

If I use the same json templater setting without the aggregator it works!

 

When I will resolve this error, I will post the right workflow.

 

Thanks

Max

Hello @geomax​ 

In the dataset you sent, the attributes required for the subtemplate is on separate features with the same id. As you have found, using an Aggregator is a one way to create one feature with the required attributes.

It is possible that the invalid value for cast/constructor error is related to null values in the attributes. If you use a NullAttributeMapper to map these values to <missing>, the error should be resolved.

I have attached an example of this workflow to this email and I hope it helps.


Hello @debbiatsafe​,

probably I resolved. The solution is to aggregate all record and attributes under the "topologycharactheristic" session. After that I used a Json templater and a json formatter to create the json as an object. at the end, i can connect these steps to the main Json templater to create the full json. My problem, now, is that using the aggregator the templater is not able to convert the string values in boolean or float in case are number and I have this message: JSONTemplater_5 (XMLTemplaterFactory): "xs:string": invalid value for cast/constructor: can not cast to "xs:float"

If I use the same json templater setting without the aggregator it works!

 

When I will resolve this error, I will post the right workflow.

 

Thanks

Max

Hello @debbiatsafe​,

it's exactly what I did to resolve the problem. Now it seems that the final result is good!

Thanks for your help and support.

 

Max

 

 


Reply