From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mz9SJ-0005mo-NL for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mz9SE-0005jV-6o for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:22 -0400 Received: from [199.232.76.173] (port=58958 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mz9SE-0005jR-1d for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:18 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:48553) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mz9SD-0000Ny-Hi for qemu-devel@nongnu.org; Sat, 17 Oct 2009 09:36:17 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e39.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9HDUNc8003224 for ; Sat, 17 Oct 2009 07:30:23 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9HDaCX7174586 for ; Sat, 17 Oct 2009 07:36:12 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n9HDaB5Q021400 for ; Sat, 17 Oct 2009 07:36:11 -0600 Received: from localhost.localdomain (sig-9-65-54-101.mts.ibm.com [9.65.54.101]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n9HDaBJA021369 for ; Sat, 17 Oct 2009 07:36:11 -0600 From: Anthony Liguori Date: Sat, 17 Oct 2009 08:36:00 -0500 Message-Id: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 0/11] json parser (v2) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org I fat-fingered the git send-email command the first time so here's the second iteration. This series introduces a json parsing framework. The parser is a recursive decent parser and implements the full json spec except for the null keyword. We need to decide how we want to model null in order to support this. In addition, we implement an extension to allow single quote strings. This is very useful for defining dictionaries in C. The parser has a full test suite and introduces a boolean and float type. It also supports varargs parsing. Here's an example of how that works: QObject *obj; obj = qobject_from_jsonf("{'id': %d, {'locked': %i, 'file': %s}}", NULL, bs->id, bs->locked, bs->file); The parser also can embed full qobjects with the '%p' format. To do streaming parsing, we need a lexer that can tokenize the input. We then just need a simple counter to look for balanced {'s and ['s. The lexer can just be a regular expression so it's pretty straight forward.