Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Good morning Community!
I have set up a service with the input Colour. The following picture shows the code inside the service.
As shown in the picture I want to send the TimeStamp (ts) first and followed by the Colour which came as input.
The property-value then somehow is the following:
Why does Thingworx cange the sequence so that there is the Colour first?
I need it in the other way, like programmed within the service. Can someone help me with that?
Yours faithfully,
Marius
Solved! Go to Solution.
Hi @MS_FLiX_HSD
As we know, JSON is an unordered set of value pairs. But what i have noticed while trying your Use case is that it is sorting values in alphabetical order. So, In case you want your time to come before instead of "ts" name it let's say "wz" or anything which comes after "t" or you can also change type into "abc".
For example, me.OrderProcess = {"ts":result, "abc": Colour}
Revert back if you still face any challenges.
Regards
Bhawna
I cannot help you with your exact issue. What I would challenge is why you need to have it in the same order? In general a json objects attribute order does not matter as you can access the attribute you want with the attribute name (e.g. me.OrderProcess.type or me.OrderProcess.ts).
The json spec also does specify that a json object is an unordered object of key/value pairs - https://stackoverflow.com/a/4920304
Unfortunately the factory awaits the payload in this order.
Hi @MS_FLiX_HSD
As we know, JSON is an unordered set of value pairs. But what i have noticed while trying your Use case is that it is sorting values in alphabetical order. So, In case you want your time to come before instead of "ts" name it let's say "wz" or anything which comes after "t" or you can also change type into "abc".
For example, me.OrderProcess = {"ts":result, "abc": Colour}
Revert back if you still face any challenges.
Regards
Bhawna
Thank you for this hint! I didn't recognize that its alphabetically. I'll try to change the names.
I don't think it is alphabetical in any case as when I tested it was not.
e.g. I assigned me.jsonProperty = {"cc": "C","aa": "A","bb": "B"};
and it was saved in the same order.
But if you find a working combination good.
Otherwise you could also set the property as type string and build the needed format on your own. me.stringProperty = "{\"ts\":\"" + result + ".....}";
In my case it was not saved in the same order. Maybe Thingworx put the time stamp at the end. But it is working now for me. I guess a String would also be possible. Thank you for reviewing!