Skip to content

Commit

Permalink
Merge pull request #41 from GPPassos/fix-tabular-character
Browse files Browse the repository at this point in the history
Interprets correctly tabular characters
  • Loading branch information
fredokun committed Jun 19, 2018
2 parents 489f93f + 4643098 commit 0d2eec1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/myjson.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ There are several libraries available for json encoding and decoding,
;(format t "escape char = ~A~%" escape-char)
(cond ((eql escape-char :eof) (error 'json-parse-error :message "Unexpected end of file (after '\')"))
((char= escape-char #\n) (vector-push-extend #\Newline str))
((char= escape-char #\t) (vector-push-extend #\Tab str))
(t
;;(vector-push-extend char str) ;; XXX: escaping is performed on the lisp side
(vector-push-extend escape-char str)))))
Expand Down Expand Up @@ -379,6 +380,9 @@ The INDENT can be given for beautiful/debugging output (default is NIL
do (cond ((char= char #\Newline)
(vector-push-extend #\\ jstr)
(vector-push-extend #\n jstr))
((char= char #\Tab)
(vector-push-extend #\\ jstr)
(vector-push-extend #\t jstr))
(t (vector-push-extend char jstr))))
jstr))

Expand All @@ -387,6 +391,10 @@ The INDENT can be given for beautiful/debugging output (default is NIL
with a new line")
=> "this is a string \\nwith a new line")

(example
(string-to-json-string "this is a string with a tabular character")
=> "this is a string\\twith a tabular character")

(example
(string-to-json-string "(format t \"hello~%\")")
=> "(format t \"hello~%\")")
Expand Down

0 comments on commit 0d2eec1

Please sign in to comment.