Bug 7009

Error importing Plain JSON string generated from ExportRowasJSON method 11 October, 2021

Matt Balent
26 July, 2021
Product: PowerBuilder Category: DataWindow
Version: 2019 R3 Build: 2703
Classification: Issue Publishing: Public
Priority: P3
Status: Verifying Reason:
Mark Lee @Appeon 11 October, 2021
#5
Hi Matt,

Just to let you know, this issue is not a bug, but a usage issue.
 
You need to modify your importjson code referring to the below so that it properly imports data into dataWindow
 
Comment your original code:
//li = dw_2.importjson(is_json)
Add new code:
li = dw_2.ImportRowFromJson(is_json, 1) 
 
If you want to import data to datawindow by using the importjson function, the JSON string must be in the format described in the section called “Supported JSON formats” in Application Techniques.:
The structure of DataWindow JSON is as follows:
{
"identity": "70c86603-983b-4bd9-adbc-259436e43cbd",
"version":1.0,
"platform":"PowerBuilder",
"mapping-method": 0,
"dataobject":{"name":"d_example",
    "meta-columns": [COLUMN-META1, COLUMN-META2…],
    "primary-rows": [DW-STANDARD-ROW1, DW-STANDARD-ROW2…],
    "filter-rows": [DW-STANDARD-ROW1, DW-STANDARD-ROW2…],
    "delete-rows": [DW-STANDARD-ROW1, DW-STANDARD-ROW2…],
    "dwchilds":{"department_id": [SIMPLE-ROW1,SIMPLE-ROW2…],
                "category_id": [SIMPLE-ROW1,SIMPLE-ROW2…]
                     …
                    }
}
}
You can refer to the following links for more details:
https://docs.appeon.com/pb2021/datawindow_reference/ch09s97.html 
https://docs.appeon.com/pb2021/application_techniques/ch04s07.html#supported_json_formats 

Regards,
Mark Lee
Mark Lee @Appeon 27 July, 2021
#4
Hi Matt,

Thanks for reporting this problem! 
We reproduced it on our end and will do further research to figure it out. 
We will keep you updated!

Regards,
Mark Lee
Thanks for providing a sample Test Case, Matt!

I will now transfer this to our main Support/Engineering team for their review and feedback.

Regards,
Francisco
Matt Balent 26 July, 2021
#2
w_dwjsonimport.zip (4KB)

run window, click Export button.  Note JSON in the MLE control, Click Import button.  Note error returned.
Hi Matt,

Thanks for reporting this issue! Could you submit a test case that manifests this issue?

Regards,
Francisco
Matt Balent 26 July, 2021
*Phenomenon; Have an external datawindow with ten columns, most of which are dddws themselves.  Insert a blank row and then perform a ExportRowasJSON to get a 'base' JSON string for this datawindow (all JSON values are NULL).  When I attempt to import this JSON back into the datawindow using the Datawindow importjson method I receive a -5 ' (JSON format error per the help)



*Reproduce Steps:


Remarks: 
The generated JSON string is valid if I use the json parser object 'LoadString' method

The importjson on the ribbonbar doesn't accept null data per the help file but this is on a datawindow.
OS:
Windows 10
Platform:
64-bit
Database Type:
SAP ASE
Database Version:
15