The code fails to access JSON object if it's key contain dots.
JSON:
"TableTraps": {
"1.3.6.1.4.1.100.108.0.3": {
"Vars": [
"alarmDescription",
"alarmPositionUnit",
"alarmChannel"
]
},
"1.3.6.1.4.1.100.108.0.4": {
"Vars": [
"alarmDescription",
"alarmPositionUnit",
"alarmChannel"
]
},
}
Pascal SuperObject code:
TableTraps := LoadFromFile();
TrapOID := '1.3.6.1.4.1.100.108.0.3';
trapInfo := TableTraps.O[TrapOID];
Results in trapInfo == nil but I expect SuperObject instance.
I've tried to wrap the json key:
TrapOID := '"' + '1.3.6.1.4.1.100.108.0.3' + '"';
or
TrapOID := '''' + '1.3.6.1.4.1.100.108.0.3' + '''';
It doesn't help.
How should I call SuperObject to access the object instance if the json key contains dots?
Related question How to serialize JSON key containing dots (like e.g. IP address) with SuperObject?
Related question helped me to find the solution. The
suprobject.Ocalled directly on the parsed object parses dots as JSONPath. So instead of accessing"1.3.6.1.4.1.100.108.0.3: {}"it tries to access this JSON:Here the workaround: