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 !
Asked: 2022-08-27 13:30:11 +0000
Seen: 1,094 times
Last updated: Aug 27 '22
solved ! Thanks !