WebAPI JSON to DataWindow

Systeembeheer SFR
Posts: 8
 3 years 11 months ago #334 by Systeembeheer SFR
Systeembeheer SFR replied the code: WebAPI JSON to DataWindow
Dear Govinda,
Thanks for your help. It's a struggle. Your script seems to work perfectly...on my desktop and is reading the kg out of the scale
Great
But when applying this to the app in de appeon app on my tablet it's not working.
It took me a while and a lot of tests to see why.

Apparently the app does nog like the orange line. Running this URL in google, i get a good response. But doing the some within the app and this code the scale response with: INDEX UNKNOW
Do you know it powerserver app can understand the geturl function (i look it up and it should). I also tried all ways with or without http:// etc. I am running out of options, but i am sure i am really close
I really appreciated all your work so far. Thanks in advance




/////code//////
inet linet_main
n_cst_internet luo_data // as defined above

linet_main = CREATE inet
luo_data = CREATE n_cst_internet

li_rc = &
linet_main.GetURL("[color=orange]172.16.12.50:9094/?index=1", luo_data)[/color]
SetPointer(Arrow!)
IF li_rc = 1 THEN
///here goes your code

Please Log in or Create an account to join the conversation.

Govinda Lopez @Appeon
Posts: 7
 3 years 11 months ago #333 by Govinda Lopez @Appeon
Govinda Lopez @Appeon replied the code: WebAPI JSON to DataWindow
Hi Systeembeheer SFR,

Using POS to obtain the value is a good approach you can use for PowerServer Mobile. You could do something like this:

// Get the position of the "net" string
li_positie = POS(ls_stringtotaal, '"net":')

// Strip out the first part of the string for ease of use
ls_temp = MID(ls_stringtotaal, li_positie + 6)

// You can use either of these lines depending on the composition of your JSON string
//li_positie = POS(ls_temp, 'consecNumber') - 2
li_positie = POS(ls_temp, ',"')

// Get the value of the kg as needed
ls_kg = MID(ls_temp, 1, li_positie - 1) + " kg"
You can reduce the amount of lines of code, of course, but I just placed them like so as an example. You can also test this code and make changes as necessary.

I hope this helps.

Regards,

Please Log in or Create an account to join the conversation.

Systeembeheer SFR
Posts: 8
 3 years 11 months ago #332 by Systeembeheer SFR
Systeembeheer SFR replied the code: WebAPI JSON to DataWindow
Ho Govinda Lopez
Thanks for your quick reply. To bat it's nog supported yet.
This leaves me with a small problem, maybe you can help me one more time.

I got this string out of our scale:
{"grossavg":0,"freefall1":0,"futurenet2":2.3,"tare":0,"target":0,"freefall2":0,"curDigitsTotal":5,"inGrossBand":false,"max":28923.3,"count":5,"pcwt":0.45359237,"futurenet1":2.3,"lastsample":1,"curCapacity":500,"adc":84489,"netmin":-1.9,"ntot":0,"roc":0,"units":2,"min":-1.9,"ctot":0,"hiresnet":2.317815209042,"gtot":0,"referenceWeight":0,"curDigitsRight":1,"resultdescr":"LIVE SUCCESS","curDivision":0.1,"ntotcal":0,"inmotion":0,"hiresgross":2.317815209042,"unitsStr":"kg","holdCounts":0,"gtotcal":0,"netavg":0,"net":2.3,"consecNumber":0,"gross":2.3,"netmax":28923.3,"futuregross1":2.3,"inmohiresnet":0,"percent":0,"underRange":false,"countavg":0,"futuregross2":2.3,"overRange":false,"resultnr":0,"holdEnabled":false,"inmohiresgross":0,"ntotpluscur":2.3,"ntotminuscur":-2.3,"gtotpluscur":2.3,"ctotminuscur":-5,"pcwtx1k":453.59237,"ctotpluscur":5,"gtotminuscur":-2.3,"curUnitsFactor":0.45359237,"motion":false,"datetimestamp":"04/01/2021 17:31:18","scaleId":1,"serialnumber":"191650375","tran":0,"centerZero":false,"adcTimeUSec":274630,"curDigitsLeft":3,"timeStamp":1609781478}

I am after the kg of the scale, they can be found after "net"

I am using the function POS now: li_positie=Pos(ls_stringtotaal, "net")
For some reason it's reconising the same as Json that this is position 36. That is correct
I just don't know how to get the kg out of this. So in this case 2,3 kg.
Is there an other function to desilate the value out of this position?
Hope to here from you

Please Log in or Create an account to join the conversation.

Govinda Lopez @Appeon
Posts: 7
 3 years 11 months ago #330 by Govinda Lopez @Appeon
Govinda Lopez @Appeon replied the code: WebAPI JSON to DataWindow
Hi Systeembeheer SFR,

Currently the JSONGenerator, JSONParser and JSONPackage objects are not supported in PowerServer Mobile (docs.appeon.com/ps2020/features_help_for...pported_objects.html).

Regards,

Please Log in or Create an account to join the conversation.