3 apr 2011 kl. 18.18, Jeff Johnson wrote:

> Most of the recent rpm-5.3.x releases have the ability
> to generate JSON (and YAML and XML) markup spewage.
> 
> E.g. this command dumps all of the metadata from the bash package in JSON:
> 
>       rpm -q --json bash

The main problem with this --json format is that it isn't JSON,
but JavaScript for Mongo. The :json format is also a bit weird
(having stray commas in the output, but none in the template ?).
The lack of trailing commas in JSON is annoying, but fixable.

It should instead be changed to output lines of *actual* JSON,
and then those can be used with the "mongoimport" tool instead ?
The .mongo formats are fine, those don't need to change to .json.
And there shouldn't be any change to the actual database format.

> That output is almost, but not quite, ready to be imported using
> the mongo shell. I've attached an example input/output to illustrate
> the minor editing that needs to be done differently (or fixed in
> the mongo shell: afaik --json is emitting valid JSON but perhaps
> I've missed some detail reading specs.)

Valid JavaScript, perhaps. Although I don't think it's either ?

e.g. all keys need to be escaped in json, but not so in mongo

> I've also prototyped the JSON analogue of repo-md with these commands:
> 
>       rpm -qa --wnh:primary.mongo
>       rpm -qa --wnh:filelists.mongo
>       rpm -qa --wnh:other.mongo

Or MongoDB analogues, actually. Though the syntax is JSON-ish.

The actual JSON can be seen by using "mongoexport" afterwards.

> Most of what remains is knocking out the usual pesky
> details on the JSON markup, like utf8 encoding everywhere, and
> with syntax adjustments to match up with specific
> parsers like the mongo JS shell, as well as the same with all the
> usual bindings of MongoDB to every bleeping interpreter.
> 
> RPM itself embeds the mongo-c-driver, and will use BSON, not JSON,
> so sanitizing the utf8 encoding and adjusting escaping and newlines
> with spewage isn't as important as getting some reasonably well
> defined schemas with known usage cases (like repo-md) defined
> conventionally. I.e. how should databases be named, what identifiers
> should be used for distros/packages/files/hosts/users, figgering 
> authentication etc, etc.

This still applies, orthogonal to the JSON vs. JavaScript issue.

> Any interest in helping with RPM+MONGODB here on the rpm-devel list?
> 
> There's *lots* of usage cases for RPM+MONGODBif you just think a bit ...
> ... consider distributing/loading macro configuration straight from a MongoDB
> for one example.

Took a while, but finally got around to looking at it for real...

--anders

______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
Developer Communication List                        rpm-devel@rpm5.org

Reply via email to