From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkwQY-0004aE-TM for qemu-devel@nongnu.org; Wed, 22 Apr 2015 11:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkwQT-00056I-1i for qemu-devel@nongnu.org; Wed, 22 Apr 2015 11:19:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkwQS-000563-QD for qemu-devel@nongnu.org; Wed, 22 Apr 2015 11:18:56 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 82B95C6A24 for ; Wed, 22 Apr 2015 15:18:56 +0000 (UTC) Message-ID: <5537BBDF.1050604@redhat.com> Date: Wed, 22 Apr 2015 09:18:55 -0600 From: Eric Blake MIME-Version: 1.0 References: <1429668155-1606-1-git-send-email-jsnow@redhat.com> <1429668155-1606-4-git-send-email-jsnow@redhat.com> <5537B176.9070508@redhat.com> <5537B87D.2070205@redhat.com> In-Reply-To: <5537B87D.2070205@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="22XUK23CpPAeRPk4j939cpGB6WMMpIh3q" Subject: Re: [Qemu-devel] [PATCH 3/5] scripts: qmp-shell: allow single-quotes in JSON expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-devel@nongnu.org Cc: kchamart@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --22XUK23CpPAeRPk4j939cpGB6WMMpIh3q Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/22/2015 09:04 AM, John Snow wrote: >> But it's still worth thinking about whether there is a more robust >> solution to be used. >> >=20 > I done looked it up: >=20 > I can probably squash patches 2&3 with a single fix to use the > ast.literal_eval() function, which does accept single or double quotes,= > since it parses python syntax instead of JSON. Our QMP parser accepts 'string' as an extension to JSON (which is "string" only). That's about the only JSON extension our parser has at the moment. Another thing to consider - JSON uses "bool-key":false while Python uses "bool-key":False (we don't yet support any QMP commands that would validly require a null argument, but JSON would use "key":null while Python uses "key":None). Once you get past that difference in spelling for True, False, and None (which could be done by string replace of bare 'true', 'false', and 'null'), then JSON is pretty much a strict subset of valid Python. Having qmp-shell be friendly and accept both JSON and Python spellings of the three keywords might actually be a nice hack. Maybe we should even extend our QMP parser to also accept True in place of true (output would still always be strict JSON, but there's no harm in making the input engine parse extensions, as we've already proven with the 'string' extension). >=20 > I could probably also just have it 'try' each method until it finds > something it likes. I haven't used qmp-shell much myself, so at this point, I'll leave it up to you how much effort you want to put into it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --22XUK23CpPAeRPk4j939cpGB6WMMpIh3q Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVN7vfAAoJEKeha0olJ0Nqjz8H/0g+uY+MC4Y4IGv604agK10n e9s0xBgQzyv63+PvbaMR4BQhGLwfaj6Yo7mk14BYqbN46HMAywWSdZ7zSRrlsaS/ rmetmRlfh6yeGcNiW5HC6xmxDChfrC3vgpgQtfSWmrglkxmSZV5FmJWRVN6sBPE5 KB5wcBw5dY9I/nADkgC/7gUFWgcAlUorN463L+n0mwDSsazhAuZ7/Guv21b8rT4L Eh4KHeHhXxck1mrEE+uxrWNSlwINQJ/9gMNFamO9lqPFpTeljEoJ5zx2f3uNvM2Y tZeq05+dHKed/UrGRcgI3ybGXJ7LpQ8PeEba5aVBvKTFpHSwKgyD97Rb7xGAnzw= =J5xR -----END PGP SIGNATURE----- --22XUK23CpPAeRPk4j939cpGB6WMMpIh3q--