diff mbox

[libnftables,2/3] table: json: fix json style

Message ID 20130930150557.32124.88117.stgit@nfdev.cica.es
State Changes Requested
Headers show

Commit Message

Arturo Borrero Sept. 30, 2013, 3:05 p.m. UTC
Be consistent in JSON style.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 0 files changed


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pablo Neira Ayuso Sept. 30, 2013, 5:43 p.m. UTC | #1
On Mon, Sep 30, 2013 at 05:05:57PM +0200, Arturo Borrero Gonzalez wrote:
> Be consistent in JSON style.

I prefer if you rewiew the entire output and you perform all this
consistency fixes in one patch.

The description should what policy you have following to fix the
style.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Hemminger Sept. 30, 2013, 6:06 p.m. UTC | #2
On Mon, 30 Sep 2013 17:05:57 +0200
Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> wrote:

> Be consistent in JSON style.
> 
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>

All the effort to format and add whitespace in JSON is not that important
since it is intended to be parsed by something, and parsers ignore it.
Many applications just use as little whitespace as possible to reduce size
of output!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso Sept. 30, 2013, 6:34 p.m. UTC | #3
On Mon, Sep 30, 2013 at 11:06:44AM -0700, Stephen Hemminger wrote:
> On Mon, 30 Sep 2013 17:05:57 +0200
> Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> wrote:
> 
> > Be consistent in JSON style.
> > 
> > Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> 
> All the effort to format and add whitespace in JSON is not that important
> since it is intended to be parsed by something, and parsers ignore it.
> Many applications just use as little whitespace as possible to reduce size
> of output!

Thanks Stephen, we'll stick to using as little whitespace as possible.

Moreover, there are tools and functions (included in libjansson) to
make this human friendly, in case anyone needs it.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arturo Borrero Sept. 30, 2013, 9:55 p.m. UTC | #4
On 30 September 2013 20:34, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Mon, Sep 30, 2013 at 11:06:44AM -0700, Stephen Hemminger wrote:
>> On Mon, 30 Sep 2013 17:05:57 +0200
>> Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> wrote:
>>
>> > Be consistent in JSON style.
>> >
>> > Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
>>
>> All the effort to format and add whitespace in JSON is not that important
>> since it is intended to be parsed by something, and parsers ignore it.
>> Many applications just use as little whitespace as possible to reduce size
>> of output!
>
> Thanks Stephen, we'll stick to using as little whitespace as possible.
>
> Moreover, there are tools and functions (included in libjansson) to
> make this human friendly, in case anyone needs it.

I also don't care so much about the format, actually (white spaces or
not..). I just tried to give some consistency.

{ \"rule\":
{ \"chain\":
{ \"set\":
{\"table\" :

I did not notice other inconsistencies in order to make a patch fixing
all of them. Maybe Alvaro knows others.
Pablo Neira Ayuso Oct. 1, 2013, 9:43 a.m. UTC | #5
On Mon, Sep 30, 2013 at 11:55:25PM +0200, Arturo Borrero Gonzalez wrote:
> On 30 September 2013 20:34, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Mon, Sep 30, 2013 at 11:06:44AM -0700, Stephen Hemminger wrote:
> >> On Mon, 30 Sep 2013 17:05:57 +0200
> >> Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> wrote:
> >>
> >> > Be consistent in JSON style.
> >> >
> >> > Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> >>
> >> All the effort to format and add whitespace in JSON is not that important
> >> since it is intended to be parsed by something, and parsers ignore it.
> >> Many applications just use as little whitespace as possible to reduce size
> >> of output!
> >
> > Thanks Stephen, we'll stick to using as little whitespace as possible.
> >
> > Moreover, there are tools and functions (included in libjansson) to
> > make this human friendly, in case anyone needs it.
> 
> I also don't care so much about the format, actually (white spaces or
> not..). I just tried to give some consistency.
> 
> { \"rule\":
> { \"chain\":
> { \"set\":
> {\"table\" :

For consistency, please send me a patch to remove the spaces. Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/table.c b/src/table.c
index c095053..93d7745 100644
--- a/src/table.c
+++ b/src/table.c
@@ -349,7 +349,7 @@  EXPORT_SYMBOL(nft_table_parse);
 static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
 {
 	return snprintf(buf, size,
-			"{\"table\" : {"
+			"{ \"table\" : {"
 			"\"name\" : \"%s\","
 			"\"family\" : \"%s\","
 			"\"flags\" : %d"
diff --git a/tests/jsonfiles/01-table.json b/tests/jsonfiles/01-table.json
index b4fc91b..3f1f715 100644
--- a/tests/jsonfiles/01-table.json
+++ b/tests/jsonfiles/01-table.json
@@ -1 +1 @@ 
-{"table" : {"name" : "filter","family" : "ip","flags" : 0}}
+{ "table" : {"name" : "filter","family" : "ip","flags" : 0}}
diff --git a/tests/jsonfiles/02-table.json b/tests/jsonfiles/02-table.json
index 01eff74..46b83a3 100644
--- a/tests/jsonfiles/02-table.json
+++ b/tests/jsonfiles/02-table.json
@@ -1 +1 @@ 
-{"table" : {"name" : "filter2","family" : "ip6","flags" : 0}}
+{ "table" : {"name" : "filter2","family" : "ip6","flags" : 0}}