Skip to content
Snippets Groups Projects
Select Git revision
  • d84028301eb7d2ebda43f0b0500116b9cad6ce6d
  • v2018.2.x default protected
  • 0x4A6F-rpi4
  • 0x4A6F-master
  • master
  • v2018.2.2-ffs
  • v2016.2.4-batmanbug
  • radv-filterd
  • v2016.2.x
  • hoodselector
  • v2016.1.x
  • babel
  • v2015.1.x
  • 2014.4.x
  • 2014.3.x
  • v2018.2.2-ffs0.1
  • v2018.2.1-ffs0.1
  • v2018.2.1
  • v2018.2-ffs0.1
  • v2018.2
  • v2018.1.4
  • v2018.1.3
  • v2018.1.2
  • v2018.1.1
  • v2018.1
  • v2017.1.8
  • v2017.1.7
  • v2017.1.6
  • v2017.1.5
  • v2017.1.4
  • v2017.1.3
  • v2017.1.2
  • v2016.2.7
  • v2017.1.1
  • v2017.1
35 results

0004-luci-lib-jsonc-allow-encoding-empty-lists.patch

Blame
  • Forked from firmware / FFS Gluon
    Source project has a limited visibility.
    0004-luci-lib-jsonc-allow-encoding-empty-lists.patch 1.16 KiB
    From: Jan-Philipp Litza <janphilipp@litza.de>
    Date: Sun, 30 Aug 2015 15:45:49 +0200
    Subject: luci-lib-jsonc: allow encoding empty lists
    
    To be consistent with the behavior of luci-lib-json, an empty Lua table
    should be encoded to an empty JSON list, not an empty JSON object.
    
    To still allow encoding empty JSON objects, the usage of anything other
    than a number or a string as a key (for example an empty table or a
    function) can be used to force encoding as an object:
    
        json.stringify({})                  -- "[]"
        json.stringify({[{}] = true})       -- "{}"
    
    Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
    
    diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
    index 827fde8..971fb12 100644
    --- a/libs/luci-lib-jsonc/src/jsonc.c
    +++ b/libs/luci-lib-jsonc/src/jsonc.c
    @@ -222,7 +222,7 @@ static int _lua_test_array(lua_State *L, int index)
     
     out:
     		lua_pop(L, 2);
    -		return 0;
    +		return -1;
     	}
     
     	/* check for holes */
    @@ -254,7 +254,7 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
     	case LUA_TTABLE:
     		max = _lua_test_array(L, index);
     
    -		if (max > 0)
    +		if (max >= 0)
     		{
     			obj = json_object_new_array();