I'm using ignition to get the data via api and I get a string of json type.
import json
import urllib2
url="http://localhost:8080/EProduction/BinWeight"
formData={
"part":"637724000A",
"bldg":"ACP-105",
"startTime":"2023-12-11 06:30:00",
"stopTime":"2023-12-11 16:29:59"
}
jsonData = json.dumps(formData)
request = urllib2.Request(url, data=jsonData,headers={'Content-Type': 'application/json'})
response = urllib2.urlopen(request)
respData = response.read()
print respData
respData = system.util.jsonDecode(respData)
print "jsonDecode:",type(respData)
print "jsonDecode:",respData
result:
{
"status":10000,
"msg":"SUCCESS",
"data":[
{
"lot":"12092 / 21",
"contQuantity":226.20000000000002
},
{
"lot":"12092 / 45",
"contQuantity":227.34999999999
},
{
"lot":"12094 / 246",
"contQuantity":226.5
},
{
"lot":"12094 / 6",
"contQuantity":224.15
},
{
"lot":"12097 / 245",
"contQuantity":227.05
},
{
"lot":"12097 / 60",
"contQuantity":220.1
}
]
}
jsonDecode: <type 'dict'>
jsonDecode: {u'msg': 'SUCCESS', u'data': [{u'contQuantity': 226.20000000000002, u'lot': '12092 / 21'}, {u'contQuantity': 227.34999999999, u'lot': '12092 / 45'}, {u'contQuantity': 226.5, u'lot': '12094 / 246'}, {u'contQuantity': 224.15, u'lot': '12094 / 6'}, {u'contQuantity': 227.05, u'lot': '12097 / 245'}, {u'contQuantity': 220.1, u'lot': '12097 / 60'}], u'status': 10000}
After system.util.jsonDecode() function conversion, dict type key-value pairs inside the change, it seems to be in accordance with the java HashList type sorting
This is not what I want.
I'd like the order of the converted structures to still be as returned by the api and that will help me to manage the data in a unified way.
How do I solve this problem?