From 5335f225374c7ed993348d15b5018411dc776bab Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Tue, 1 Sep 2015 16:17:23 +0200 Subject: luci-lib-jsonc: Add ltn12-compatible sink factory To use the luci-lib-jsonc parser as sink for an ltn12 pump (for example from stdin), the following code will now do: require 'luci.ltn12' require 'luci.jsonc' local parser = luci.jsonc.new() luci.ltn12.pump.all(luci.ltn12.source.file(io.input()), parser:sink()) print(parser:get()) Signed-off-by: Jan-Philipp Litza --- documentation/api/modules/luci.jsonc.parser.html | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'documentation/api/modules/luci.jsonc.parser.html') diff --git a/documentation/api/modules/luci.jsonc.parser.html b/documentation/api/modules/luci.jsonc.parser.html index 4c19cf0e59..e8e145f437 100644 --- a/documentation/api/modules/luci.jsonc.parser.html +++ b/documentation/api/modules/luci.jsonc.parser.html @@ -233,6 +233,13 @@ Convert parsed JSON data into Lua table. Put Lua data into the parser. + + parser:sink () + + +Generate an ltn12-compatible sink. + + parser:stringify (pretty) @@ -406,6 +413,34 @@ Nothing is returned. +
parser:sink ()
+
+ + +Generate an ltn12-compatible sink. + + + + + + +

Usage:

+
parser = luci.jsonc.new() 
+ltn12.pump.all(ltn12.source.file(io.input()), parser:sink()) 
+print(parser:get())
+ + + +

Return value:

+Returns a function that can be used as an ltn12 sink. + + + +
+ + + +
parser:stringify (pretty)
-- cgit v1.2.3