1. Bjarne Anker
  2. PowerBuilder
  3. Tuesday, 22 March 2022 07:13 AM UTC

Hi.

We're currently developing a service for fetching realtime currency from a online broker.

The result is a JSON, like this:

[
{
"symbol": "USD/NOK",
"timestamp": "2022-03-22T06:58:35.690285Z",
"rate": 1.566015
},
{
"symbol": "SEK/NOK",
"timestamp": "2022-03-22T06:58:35.690370Z",
"rate": 1.566015
}
]

My datastore is like this:

When i run ln_rest.retrieve(ln_ds,ls_url), I get error -16 - "The JSON is not a plain JSON with two-level structure".

However, the respons looks exactly like one of the examples in the documentation (The section called "Plain JSON"), and is indeed a two-level JSON.

Brackets and curly braces indicates an array of two objects as far as I know.

So what's the reason why my restclient.retrieve fails?

 

Note: I works just fine if I collect the responsebody and parse it using the JSONParser object.

 

Update: it seems that restclient.retrieve() does not support other than string, integer, boolean or null:

"A plain JSON can only contain elements of the following 4 data types: integer, string, boolean, and null."

So I guess the decimal is causing the error message?

If so, that's a really big limit which has to be sorted.

 

Using PB 2019R3.

 

br,

 

Bjarne Anker

Maritech Systems AS

Norway

 

Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 March 2022 08:09 AM UTC
  2. PowerBuilder
  3. # 1

Hi Bjarne,

 

Thanks for reporting this problem.

We can not reproduce this problem based on the information you provide in PB 2019 R3 Build 2728.

If you use the HTTPClient object to directly access the URL, do you get the same JSON result as you provided?

 

In our test and analysis, we can use the ImportJSON method to import the JSON content into the DataWindow. Refer to the following code:

dw_data.ImportJson(ls_json, Primary!)

In addition, in your C # code, is the timestamp key defined as string type or Datetime type in the model?

If it is a Datetime type, it is recommended that you upgrade to PB 2021 Build 1506 to verify this problem.

 

If the above information does not help, it is recommended that you report this issue to our ticket system: https://www.appeon.com/standardsupport/newbug so that it can be properly received and tracked.

Please also provide a sample test case (with PBT / PBL + C# API code) when you submit it to the ticket system. 

 

Regards,

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 22 March 2022 14:26 PM UTC
  2. PowerBuilder
  3. # 2

Hi Bjarne ;

   I have had the same issue and resolved it by A) Editing the JSON data stream under PowerScript to make it DWO compliant or B) using the JSONParser object as you mentioned. The DWO is very sensitive on what JSON structure(s) it can handle.

Regards ... Chris

Comment
  1. Bjarne Anker
  2. Wednesday, 23 March 2022 07:24 AM UTC
Ok, It seems that JSONParser is the best option right now.

But I will try to modify the response to make the DWO option work as well.

Do you think it's the decimal number causing problems?

Otherwise the JSON looks to be as it should.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.