| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 15 | class UaJSONEncoder(JSONEncoder): |
||
| 16 | """ |
||
| 17 | JSON encoder utility which is extended to handle opc ua objects |
||
| 18 | """ |
||
| 19 | def default(self, o): |
||
| 20 | if isinstance(o, datetime): |
||
| 21 | return { |
||
| 22 | '__type__': 'datetime', |
||
| 23 | 'year': o.year, |
||
| 24 | 'month': o.month, |
||
| 25 | 'day': o.day, |
||
| 26 | 'hour': o.hour, |
||
| 27 | 'minute': o.minute, |
||
| 28 | 'second': o.second, |
||
| 29 | 'microsecond': o.microsecond |
||
| 30 | } |
||
| 31 | elif isinstance(o, ua.NodeId): |
||
| 32 | return { |
||
| 33 | '__type__': 'NodeId', |
||
| 34 | 'Identifier': o.Identifier, |
||
| 35 | 'NamespaceIndex': o.NamespaceIndex, |
||
| 36 | } |
||
| 37 | else: |
||
| 38 | return JSONEncoder.default(self, o) |
||
| 39 | |||
| 61 |