Permalink
Browse files

* Add escaping of backslash to json output

  * Add escaping of foward slash on tokenizing and output
  * Changes to internal tokenizer from using recursion to
    using a depth state structure to allow incremental parsing


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@14 327403b1-1117-474d-bef2-5cb71233fd97
  • Loading branch information...
1 parent 837240f commit a850f8e29e8aeb3f7c94210376012c50251912d0 @michaeljclark michaeljclark committed Mar 13, 2007
Showing with 307 additions and 193 deletions.
  1. +7 −6 COPYING
  2. +6 −0 ChangeLog
  3. +1 −1 Makefile.am
  4. +5 −1 json_object.c
  5. +228 −177 json_tokener.c
  6. +34 −8 json_tokener.h
  7. +26 −0 test1.c
View
@@ -10,9 +10,10 @@ Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
@@ -1,3 +1,9 @@
+0.7
+ * Add escaping of backslash to json output
+ * Add escaping of foward slash on tokenizing and output
+ * Changes to internal tokenizer from using recursion to
+ using a depth state structure to allow incremental parsing
+
0.6
* Fix bug in escaping of control characters
Johan Bj�rklund, johbjo09 at kth dot se
View
@@ -1,4 +1,4 @@
-CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
+AM_CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
lib_LTLIBRARIES = libjson.la
View
@@ -1,5 +1,5 @@
/*
- * $Id: json_object.c,v 1.15 2006/01/30 23:07:57 mclark Exp $
+ * $Id: json_object.c,v 1.17 2006/07/25 03:24:50 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
* Michael Clark <michael@metaparadigm.com>
@@ -93,13 +93,17 @@ static int json_escape_str(struct printbuf *pb, char *str)
case '\r':
case '\t':
case '"':
+ case '\\':
+ case '/':
if(pos - start_offset > 0)
printbuf_memappend(pb, str + start_offset, pos - start_offset);
if(c == '\b') printbuf_memappend(pb, "\\b", 2);
else if(c == '\n') printbuf_memappend(pb, "\\n", 2);
else if(c == '\r') printbuf_memappend(pb, "\\r", 2);
else if(c == '\t') printbuf_memappend(pb, "\\t", 2);
else if(c == '"') printbuf_memappend(pb, "\\\"", 2);
+ else if(c == '\\') printbuf_memappend(pb, "\\\\", 2);
+ else if(c == '/') printbuf_memappend(pb, "\\/", 2);
start_offset = ++pos;
break;
default:
Oops, something went wrong. Retry.

0 comments on commit a850f8e

Please sign in to comment.