* Nick Jenkins nickpj@gmail.com [2006-08-11 16:19:18 +1000]:
Actually, even better would be to:
- change to JSON format ( http://www.json.org/ )
- omit the "http://en.wikipedia.org/wiki/" bit (and let the web UI add this instead)
- use a different array for each element, rather than 3 different arrays for the different fields (thus grouping all the fields for
one element together).
- use the [] notation instead of array notation (which is part of the JSON spec anyway).
In other words, using a real example, if the TcpQuery results for a search on "cat" were changed from this current result:
sendRes("cat", new Array("Catholics → Roman Catholic Church", "Catholic Archibishop → Bishop", "Catholic", "Catholic Pope → Pope", "CATV → Cable television", "Catalogue astrographique → Star catalogue", "Catholic Encyclopedia", "Catalonia", "Cattle", "Catholicism"), new Array("7505", "4484", "4200", "3269", "2347", "2095", "1956", "1740", "1604", "1527"), new Array("http://en.wikipedia.org/wiki/Roman_Catholic_Church", "http://en.wikipedia.org/wiki/Bishop", "http://en.wikipedia.org/wiki/Catholic", "http://en.wikipedia.org/wiki/Pope", "http://en.wikipedia.org/wiki/Cable_television", "http://en.wikipedia.org/wiki/Star_catalogue", "http://en.wikipedia.org/wiki/Catholic_Encyclopedia", "http://en.wikipedia.org/wiki/Catalonia", "http://en.wikipedia.org/wiki/Cattle", "http://en.wikipedia.org/wiki/Catholicism"));
To this:
["cat", ["Catholics", 7505, "Roman Catholic Church"], ["Catholic Archibishop", 4484, "Bishop"], ["Catholic", 4200, ], ["Catholic", 3269, ], ["CATV", 2347, "Cable television"], ["Catalogue astrographique", 2095, "Star catalogue"], ["Catholic Encyclopedia", 1956, ], ["Catalonia", 1740, ], ["Cattle", 1604, ], ["Catholicism", 1527, ] ]
Then it would have the following benefits:
- Less data is transmitted (by my count approximately 840 bytes versus 322 bytes, or a saving on 62%).
- The data can still be passed to an JS eval() to evaluate it.
- The redirects are in a different field, instead of merged into the first field.
- It's in a standard data format, so if other services wanted to talk to TcpQuery, this would make that easier.
- To me, the second of those data formats seems simpler (but this may just be my personal preference).
I am agree to use this format instead of the previous one, it is better. But the url need to be added since it is different of the title(but without the http://en.wikipedia.org/wiki/).
I will give modifiy the TcpQuery to give result in json with an array of 4 entry : [url, name, frequency, redirect] for example : ["cat", ["Roman_Catholic_Church", "Catholics", 7505, "Roman Catholic Church"], ...
Did you used json in EMCAsript/javascript ?
Best Regards. Julien Lemoine