#XPRIM_JsonObject
Posted: Fri Mar 22, 2019 3:59 pm
I'm calling a web service which returns an array of objects like this
{
"SchoolsList": [
{
"Account": "f488553b-d025-dc11-803a-00118581f25d",
"AccountName": "Vistara Primary School",
"DECId": null,
"NESAId": "77579"
},
{
"Account": "a2251935-80fa-da11-8d33-00118581f25d",
"AccountName": "Giant Steps Sydney",
"DECId": null,
"NESAId": "11837"
},
There are almost 4000 items in this list and it take 2 minutes to read from beginning to end and extract the 4 fields. This seems like a long time for an essentially in memory operation on a big fast iseries. it took less than 2 seconds to retrieve the data.
I'm doing (see below). Is there a faster way to do this?
Define_Com Class(#XPRIM_JsonReader) Name(#Reader)
Define_Com Class(#XPRIM_JsonObject) Name(#Item) Reference(*DYNAMIC)
#Reader.SetSourceHttpResponse Httpresponse(#Request.Response) Errorinfo(#ErrorInfo)
#Reader.ReadBeginArray Found(#OK)
#Reader.MoveNext Ok(#OK)
Dowhile Cond(#OK *And (*Not #Reader.IsEndArray))
#Reader.ReadObject Found(#OK) Result(#Item)
If Cond(#OK)
#WRK50A := #item.GetString( 'Account' ).AsNativeString
#SCHLNM := #item.GetString( 'AccountName' ).AsNativeString
#wrk5n0 := #item.GetNumber( 'DECId' )
#wrk6n0 := #item.GetNumber( 'NESAId' )
Endif
#Reader.MoveNext Ok(#OK)
Endwhile
{
"SchoolsList": [
{
"Account": "f488553b-d025-dc11-803a-00118581f25d",
"AccountName": "Vistara Primary School",
"DECId": null,
"NESAId": "77579"
},
{
"Account": "a2251935-80fa-da11-8d33-00118581f25d",
"AccountName": "Giant Steps Sydney",
"DECId": null,
"NESAId": "11837"
},
There are almost 4000 items in this list and it take 2 minutes to read from beginning to end and extract the 4 fields. This seems like a long time for an essentially in memory operation on a big fast iseries. it took less than 2 seconds to retrieve the data.
I'm doing (see below). Is there a faster way to do this?
Define_Com Class(#XPRIM_JsonReader) Name(#Reader)
Define_Com Class(#XPRIM_JsonObject) Name(#Item) Reference(*DYNAMIC)
#Reader.SetSourceHttpResponse Httpresponse(#Request.Response) Errorinfo(#ErrorInfo)
#Reader.ReadBeginArray Found(#OK)
#Reader.MoveNext Ok(#OK)
Dowhile Cond(#OK *And (*Not #Reader.IsEndArray))
#Reader.ReadObject Found(#OK) Result(#Item)
If Cond(#OK)
#WRK50A := #item.GetString( 'Account' ).AsNativeString
#SCHLNM := #item.GetString( 'AccountName' ).AsNativeString
#wrk5n0 := #item.GetNumber( 'DECId' )
#wrk6n0 := #item.GetNumber( 'NESAId' )
Endif
#Reader.MoveNext Ok(#OK)
Endwhile