Juliusz Chroboczek <j...@irif.fr> writes: >> Nils and I wrote such a daemon, called mmfd. It is able to forward >> multicast packets in the whole network. To learn about the topology and >> the relevant neighbours, it queries babeld: mmfd is listening via >> "monitor" on the babeld socket. > > Good. > >> What do you think of providing the same data over json to make it better >> parsable? > > The format of the monitoring interface is well defined : it's a series of > lines of the form > > keyword id key value key value ... > > where each key/value is either space separated, or a string within double > quotes. > > This format is extensible (we can add new keywords and new keys at any > time), and it's also easy to parse by a human (Antonin and I have just > spent much of today telnetting by hand into Babel's monitoring > interface). So I'm not convinced that switching to JSON would have any > benefits.
The main benefit of a well-known format is that the requirement for a client goes from easy parsing code to *no* parsing code. In this example, parsing the custom format in Python would be something like: data = {} for line in input: keyword, id, rest = line.split(" ", 3) data[keyword] = {'id': id} parts = rest.split(" ") # wait, this doesn't deal with quoted values for key, val in zip(parts[::2], parts[1::2]): data[keyword][key] = val vs data = json.loads(input) Also, if you pretty-print the json it is quite human-readable; try e.g. `cat datafile.json | python -m json.tool` -Toke _______________________________________________ Babel-users mailing list Babel-users@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/babel-users