Can anyone tell me what format this uh.. nested dictionary is?
from luthis@lemmy.nz to linux@lemmy.ml on 11 Dec 2023 01:16
https://lemmy.nz/post/4295047

cross-posted from: lemmy.nz/post/4294116

I have a file with content like this:

item({
     ["attr"] = {
        ["size"] = "62091";
        ["filename"] = "qBuUP9-OTfuzibt6PQX4-g.jpg";
        ["stamp"] = "2023-12-05T19:31:37Z";
        ["xmlns"] = "urn:xmpp:http:upload:0";
        ["content-type"] = "image/jpeg";
     };
     ["key"] = "Wa4AJWFldqRZjBozponbSLRZ";
     ["with"] = "email@address";
     ["when"] = 1701804697;
     ["name"] = "request";
});

I need to know what format this is, and if there exists a tool in linux already to parse this or if I need to write one myself?

Thanks!

#linux

threaded - newest

offspec@lemmy.nicknakin.com on 11 Dec 2023 02:37 next collapse

It’s probaly Lua

Bankenstein@feddit.de on 11 Dec 2023 08:28 next collapse

It’s Lua.

callyral@pawb.social on 12 Dec 2023 02:46 collapse

Lua function “item” called with argument of type table

The function is the outer part with the parentheses, the table is the inner part with the curly braces. [“attr”] is a table inside the table.

For example, to access (table)>attr>size you would write: table[“attr”][“size”] (assuming the table is named, that is, assigned to a variable called “table”)

moomoomoo309@programming.dev on 12 Dec 2023 21:59 collapse

This is correct. You can also omit the parentheses on the function call in Lua if the only argument is a table or string literal.