Ask Your Question
0

Parse JSON data in lua dissector

asked 2022-08-27 13:30:11 +0000

bq gravatar image

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 ?

edit retag flag offensive close merge delete

Comments

solved ! Thanks !

bq gravatar imagebq ( 2022-08-28 17:05:25 +0000 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-08-27 18:14:34 +0000

Chuckc gravatar image

(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
edit flag offensive delete link more

Comments

I have got this library from https://github.com/craigmj/json4lua It works well from my dissector !

Thank you very much !

bq gravatar imagebq ( 2022-08-28 17:04:11 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-08-27 13:30:11 +0000

Seen: 1,242 times

Last updated: Aug 27 '22