Page 1 of 1

JSON Data Structure and Templates

Posted: Mon Dec 24, 2018 10:07 pm
by Doghousedev
I am getting my report data from a REST Service which provides valid JSON. I cannot change how the JSON data is formatted on the server side.

I am having a difficult time building an invoice which draws its sections from 4 different tables. Each REST call returns the data, however, the return JSON is always structured with the same Node naming (see below).

Does each JSON resource and data source need to be uniquely named? When I create a report template it always fails to Preview unless the 1st Node "platform" is unique. I can render reports fine using one JSON file, but cannot get it to work with more than 1 JSON data source.

ITEM DESCRIPTIONS

Code: Select all

{"platform": {
  "message": {
    "code": "0",
    "description": "Success"
  },
  "record": [
    {"description": "PROX,SLIDE PLT,15X10"},
    {"description": "Media Presentation Audio Amplifier"},
    {"description": "OFR IN-WALL END FITTING"}[
    }
LABOR CODES

Code: Select all

{"platform": {
  "message": {
    "code": "0",
    "description": "Success"
  },
  "record": [
    {
      "created_id": "af55a8e3284b46889b74c2088b0a26e5",
      "date_created": "2018-12-06T17:40:39.000Z",
      "date_modified": "2018-12-06T17:51:03.000Z",
      "ext_labor_rate": "2045.04",
      "ext_price": "3146.215384615384",
      "id": "101892637",
      "labor_phase": "1128024210",
      "labor_phase_text": "400-PROJECT-MGT",
      "labor_rate": "85.21",
      "modified_id": "af55a8e3284b46889b74c2088b0a26e5",
      "object_id": "2525f59f406642359cb8e99931f52ceb",
      "owner_id": "2121522889",
      "price_modifier": "P35",
      "qty": "24.0",
      "quote_related_to": "1684645886",
      "sell_price": "131.09230769230768"
    }]
    }

Re: JSON Data Structure and Templates

Posted: Thu Dec 27, 2018 2:29 pm
by Lech Kulikowski
Hello,

Please send us your report with test data which reproduces the issue for analysis.

Thank you.

Re: JSON Data Structure and Templates

Posted: Sat Jan 05, 2019 4:01 pm
by Doghousedev
SOLVED:

The solution to the problem is to rename the 'root' node of each JSON file.

In my javascript function, I simply used a string replacement with regex. I created a unique 'node name' for each JSON file processed.

It worked very well.

Re: JSON Data Structure and Templates

Posted: Sun Jan 06, 2019 7:56 am
by Andrew
Hello,

Thank you very much for sharing the solution.

Have a nice day!