File: ser.py

package info (click to toggle)
zeekctl 2.2.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,544 kB
  • sloc: python: 5,639; sh: 1,374; makefile: 71; awk: 24
file content (15 lines) | stat: -rw-r--r-- 412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import json

from ZeekControl import node
from ZeekControl import cmdresult

class MyJsonEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, node.Node):
            return obj.to_dict()
        if isinstance(obj, cmdresult.CmdResult):
            return obj.to_dict()
        return json.JSONEncoder.default(self, obj)

def dumps(obj):
    return json.dumps(obj, cls=MyJsonEncoder)