Parse JSON data in lua dissector
Hello,
In a dissector written in LUA, I would like to convert json string to object.
Is there any library that I could call from the dissector ?
(This looks straightforward but I haven't tested yet)
The CloudShark Plugin for Wireshark uses/provides json.lua.
-- JSON4Lua: JSON encoding / decoding support for the Lua language. -- json Module. -- Author: Craig Mason-Jones -- Homepage: http://json.luaforge.net/ -- Version: 0.9.50 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- -- USAGE: -- This module exposes two functions: -- encode(o) -- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string. -- decode(json_string) -- Returns a Lua object populated with the data encoded in the JSON string json_string.
As used in cloudshark.lua
:
cdebug(string.format("Processing JSON response from %s", url)) if response_page ~= "[]" then parseok, response_json = pcall(json.decode, response_page) end
I have got this library from https://github.com/craigmj/json4lua It works well from my dissector !
Thank you very much !
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2022-08-27 13:30:11 +0000
Seen: 1,182 times
Last updated: Aug 27 '22
Generate dissector from JSON message description
How can I save the packet list exactly as Wireshark is displaying it as a JSON?
how to invert two bytes in lua script dissector ?
Adjusting Bit order and Endianess in LUA between Dissectors
Error while creating a Lua listener in 2.4.2 with filter
http2 decrypted data in tshark lua script
Decode as LUA - how do I do that?
solved ! Thanks !