Nmap Development mailing list archives
Re: json library
From: Daniel Miller <bonsaiviking () gmail com>
Date: Fri, 1 Jul 2011 12:45:10 -0500
David, I agree, the original patch was clunky; script writers shouldn't have to know to set metatables to invoke functionality. The patch I just attached is better: it introduces two functions, make_array and make_object, that do the metatable-setting, while preserving any existing metatable entries. Also, the json.typeof function will return the JSON type that any variable would be treated as, using both the metatable and heuristic behaviors. Finally, json.parse will now always set the proper metatable entries. Dan On 7/1/11, David Fifield <david () bamsoftware com> wrote:
On Wed, Jun 29, 2011 at 10:29:20AM -0500, Daniel Miller wrote:Lua has a built-in way to signal different behaviors: metatables. Here's a patch for the json library that checks the metatable for a "json" key. It can be set to "array" or "object", to override the default behavior.This is clever, Daniel. I don't know if it's the best solution, but it seems all right. Don't forget the other part though--json.parse needs to set the metatable entries. David Fifield
Attachment:
json.diff
Description:
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: json library David Fifield (Jul 01)
- <Possible follow-ups>
- Re: json library David Fifield (Jul 01)
- Re: json library Daniel Miller (Jul 01)
- Re: json library Toni Ruottu (Jul 03)
- Message not available
- RE: json library Daniel Miller (Jul 03)
- Re: json library Toni Ruottu (Jul 03)
- Re: json library Daniel Miller (Jul 01)