This line of code used to work, as in replacing the old processID with the new one.
‘systemstatus_thing’ holds the JSON-string fetched via a REST-call, ‘openHAB_PID’ holds the processID.
Hmmm, are you sure the newline isn’t in openHAB_PID? Are you getting that using executeCommandLine? There is almost always a newline at the end of the output from a command. In other words, your original problem is still there.
The order doesn’t matter with JSON. Remember you parsed it into a JS Object and then serialized it back to a String, you are not editing a string in place. There is no reason it has to write the values back out in the same order. It probably put it last because it changed which changed it’s position in memory.
You nailed it, as usual! Thanks.
The other problem ( the additional .pid field) was inserted as I should have specified the correct “sub” field in the whole JSON. Without such the above command just added this field at the end.