As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Hi ALL, Can help to advise how a procedure can parse a JSON string? my sample codes as below, but it not works, where 'data' is the DB column that contains the JSON string.
SQL select data from GTT_CP_RE_RES_083 where STAFF_ID='STAFF A';
TABLE -*ON TABLE HOLD AS test ON TABLE HOLD FORMAT JSON -RUN
You should not HOLD FORMAT JSON, but before retrieving the data you should already have a masterfile (GTT_CP_RE_RES_083) defined on the JSON structure in the data column.
Originally posted by Frans: You should not HOLD FORMAT JSON, but before retrieving the data you should already have a masterfile (GTT_CP_RE_RES_083) defined on the JSON structure in the data column.
Thanks Frans, Firstly, yes, my code may be wrong, can you help to advise what is the correct way to read and parse the JSON string in the fex?
Secondly,Yes, i have a masterfile called GTT_CP_RE_RES_083, but how to define the JSON structure in the data column?
Below is the master file in text view: FILENAME=GTT_CP_RE_RES_083, SUFFIX=SQLORA , $ SEGMENT=GTT_CP_RE_RES_083, SEGTYPE=S0, $ FIELDNAME=STAFF_ID, ALIAS=STAFF_ID, USAGE=A100V, ACTUAL=A100V, $ FIELDNAME=TRIGGER_DATE, ALIAS=TRIGGER_DATE, USAGE=HYYMDm, ACTUAL=HYYMDm, $ FIELDNAME=REPORT_ID, ALIAS=REPORT_ID, USAGE=A65V, ACTUAL=A65V, $ FIELDNAME=SECTION_NAME, ALIAS=SECTION_NAME, USAGE=A100V, ACTUAL=A100V, $ FIELDNAME=DATA, ALIAS=DATA, USAGE=A4000V, ACTUAL=A4000V, $
I am assuming you created this master file using WebFOCUS and not manually. I don't think you can break this down further unless you do it manually which would be very tedious. Based on your sample you may be able to use GETTOK to see the individual values but I have never tried it. I have pinged the product manager but he is on vacation until next week.
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005
And then finally, reporting from the relational table:
TABLE FILE CAR_DATA
"Car Data Report"
PRINT COUNTRY AS 'Country'
CAR AS 'Car'
FID AS 'Facility Id'
FNAME AS 'Facility Name'
ON TABLE SET STYLE *
INCLUDE = endeflt, $
ENDSTYLE
END
I am assuming you created this master file using WebFOCUS and not manually. I don't think you can break this down further unless you do it manually which would be very tedious. Based on your sample you may be able to use GETTOK to see the individual values but I have never tried it. I have pinged the product manager but he is on vacation until next week.
Hi Chuck, Thanks for your assist, yes, the master file is generated by webfocus and not manually, just i go to text view to copy it to here. please help to check with the production manager that how we can mapping to JSON data columns in DB using UI if possible.
And then finally, reporting from the relational table:
TABLE FILE CAR_DATA
"Car Data Report"
PRINT COUNTRY AS 'Country'
CAR AS 'Car'
FID AS 'Facility Id'
FNAME AS 'Facility Name'
ON TABLE SET STYLE *
INCLUDE = endeflt, $
ENDSTYLE
END
Hi David, Thanks for your nice demo, i did it same that works. But our JSON string maybe more complex, i.e. 2nd sub-level subject or 3rd sub-level subject may included, in that case how we can do it? change more on the master file codes?
Actually you don't even need to the JSON data to a file. Open the synonym for the table with a JSON field the Synonym Editor, right click on that field and select Pivot, Multiple Values to rows, if the table is large enter the number of rows to sample and click next, for Select data type choose JSON and click Apply.
The synonym editor adds a new segment that describes the JSON data.
N/A
Posts: 397 | Location: New York City | Registered: May 03, 2007
Originally posted by Clif: Actually you don't even need to the JSON data to a file. Open the synonym for the table with a JSON field the Synonym Editor, right click on that field and select Pivot, Multiple Values to rows, if the table is large enter the number of rows to sample and click next, for Select data type choose JSON and click Apply.
The synonym editor adds a new segment that describes the JSON data.
Thanks Clif, may i know that if the Synonym Editor is available for every kind of user? i right lick on the JSON field from the master file, but cannot find any Pivot option. can give me a detail steps or screenshots? thanks.
You can use the Synonym Editor in the Data Management Console or from the Reporting Server Console. Here's an example using the latter. Open the synonym, right click on the field containing the JSON and select Pivot, Multiple values to colulmns.
Then you can see the elements of the JSON as individual fields.
N/A
Posts: 397 | Location: New York City | Registered: May 03, 2007
Thanks for your nice demo, i did it same that works.
You are welcome. That is great it worked for you.
quote:
But our JSON string maybe more complex, i.e. 2nd sub-level subject or 3rd sub-level subject may included, in that case how we can do it? change more on the master file codes?
Yes if your JSON has parent - child relationships, those relationships would be defined in the Master File Definition (PARENT= segment attributes).
I created some JSON, with parent - child relationships...
I then created a sample MS SQL Server table containing a couple of occurrences of the JSON:
Then I took the following steps: 1. Created the MFD for the relational table using the GUI Synonym Builder. 2. Created the MFD for the JSON using the GUI Synonym Builder reading a flat file containing the JSON sample. Thanks Efrem! 3. Cut and pasted the JSON MFD into the SQL MFD, and made a couple of required edits.
Looks like this technique is documented in the Adapter manual in the 'How to Access JSON Data From an RDBMS Manually' section. :-)
Then, finally reporting from the relational table:
TABLE FILE CARDATA
"Car Data by Country"
SUM NUMBEROFPLANTS AS 'Number of,Plants'
VOLUMESTEELIMPORTS AS 'Steel Imports,Volume'
BY COUNTRY AS 'Country'
PRINT MODELS NOPRINT
BY COUNTRY
BY NAME AS 'Car'
BY MODELS AS 'Model'
-*
ON TABLE SET STYLE *
INCLUDE = endeflt,$
TYPE=TITLE, JUSTIFY=CENTER,$
ENDSTYLE
END
(I didn't see the 'PIVOT' tool menu option suggested by Cliff, in my particular release, but I'll look for it when we upgrade.)This message has been edited. Last edited by: David Briars,