Philip Brown wrote:
> Why the "strong" recommendation?
Because an existing and well-used implementation is likely to have more
bugs ironed out, more features (UTF-8 support, for example), and possibly
better performance than something you can whip together in a weekend.
That said, if it works for you, go for it.
> Speaking of JSON, though, it claims on the json.org page:
>
> " . It is easy for humans to read and write."
>
>
> I would amend that to say,
> It is easy for humans to read and write, *if you use line breaks*
Agreed.
> Which you don't, in the IPS catalog.
> Which was rather mean of you.
Yes, we're bad bad people, intent on making everyone's life hard.
Turns out the number of newlines (and indentation, which is just as
critical to being able to sight-read JSON) ends up being a hefty amount of
both disk space and parsing time (I don't remember whether the time is I/O
CPU).
Given the primary use of the catalog by the packaging tools, and not by
humans or line-oriented unix utilities, it seemed like a pretty decent
tradeoff, especially how easy it is to write something to pretty-print it:
#!/usr/bin/python
import sys
import simplejson as json
if len(sys.argv) > 1:
path = sys.argv[1]
else:
path = "-"
# There are extraneous parens around the file; so eliminate them.
try:
if path == "-":
js = json.load(sys.stdin)
else:
js = json.load(file(path))
except ValueError:
js = json.loads(file(path).read()[1:-1])
json.dump(js, sys.stdout, indent=2, sort_keys=True)
print
I wrote that to pretty-print the firefox sessionstore file, which has the
same issue.
> I'm also wondering why, if JSON format is so wonderful, there is no
> /usr/lib/libjson.so or some such, in Solaris 11?
There are all sorts of wonderful things that aren't in a library in
Solaris. If you think it would make your life easier, then I'd suggest
contacting your support representative to file an RFE for such a beast, as
that'll help prioritize getting it added.
> The built in "stupidparser(tm)" is good enough for my immediate needs.
Cool. There's always a lot of fun in just writing code from scratch.
Danek
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss