aboutsummaryrefslogtreecommitdiff
path: root/examples/py-json-stdout
diff options
context:
space:
mode:
Diffstat (limited to 'examples/py-json-stdout')
-rwxr-xr-xexamples/py-json-stdout/json-stdout.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/examples/py-json-stdout/json-stdout.py b/examples/py-json-stdout/json-stdout.py
index ac94d707f..9f58d161e 100755
--- a/examples/py-json-stdout/json-stdout.py
+++ b/examples/py-json-stdout/json-stdout.py
@@ -8,13 +8,9 @@ import nDPIsrvd
from nDPIsrvd import nDPIsrvdSocket, TermColor
-def parse_json_str(json_str):
-
- j = nDPIsrvd.JsonParseBytes(json_str[0])
- nDPIdEvent = nDPIsrvd.nDPIdEvent.validateJsonEventTypes(j)
- if nDPIdEvent.isValid is False:
- raise RuntimeError('Missing event id or event name invalid in the JSON string: {}'.format(j))
- print(j)
+def onJsonLineRecvd(json_dict, current_flow, global_user_data):
+ print(json_dict)
+ return True
if __name__ == '__main__':
argparser = nDPIsrvd.defaultArgumentParser()
@@ -26,9 +22,4 @@ if __name__ == '__main__':
nsock = nDPIsrvdSocket()
nsock.connect(address)
-
- while True:
- received = nsock.receive()
- for received_json_pkt in received:
- parse_json_str(received_json_pkt)
-
+ nsock.loop(onJsonLineRecvd, None)