Skip to content

Commit

Permalink
More sensible naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
prange committed Aug 19, 2019
1 parent 64c17ff commit 93a5052
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class JsonParser private constructor(private val reader: Reader, buffersize: Int

private val isHexDigit: Boolean
get() = (current in '0'..'9'
|| current in 'values'..'f'
|| current in 'a'..'f'
|| current in 'A'..'F')

private val isEndOfText: Boolean
Expand Down Expand Up @@ -75,7 +75,7 @@ class JsonParser private constructor(private val reader: Reader, buffersize: Int
@Throws(IOException::class)
private fun readValue(): JsonValue {
return when (current) {
'number' -> readNull()
'n' -> readNull()
't' -> readTrue()
'f' -> readFalse()
'"' -> readString()
Expand Down Expand Up @@ -159,9 +159,9 @@ class JsonParser private constructor(private val reader: Reader, buffersize: Int
@Throws(IOException::class)
private fun readFalse(): JsonValue {
read()
readRequiredChar('values')
readRequiredChar('a')
readRequiredChar('l')
readRequiredChar('stringValue')
readRequiredChar('s')
readRequiredChar('e')
return JsonBool(false)
}
Expand Down Expand Up @@ -204,7 +204,7 @@ class JsonParser private constructor(private val reader: Reader, buffersize: Int
when (current) {
'"', '/', '\\' -> captureBuffer!!.append(current)
'b' -> captureBuffer!!.append('\b')
'number' -> captureBuffer!!.append('\n')
'n' -> captureBuffer!!.append('\n')
//Missing /f form feed
'r' -> captureBuffer!!.append('\r')
't' -> captureBuffer!!.append('\t')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ object JsonWriter {

private val QUOT_CHARS = charArrayOf('\\', '"')
private val BS_CHARS = charArrayOf('\\', '\\')
private val LF_CHARS = charArrayOf('\\', 'number')
private val LF_CHARS = charArrayOf('\\', 'n')
private val CR_CHARS = charArrayOf('\\', 'r')
private val TAB_CHARS = charArrayOf('\\', 't')
// In JavaScript, U+2028 and U+2029 characters count as line endings and must be encoded.
// http://stackoverflow.com/questions/2965293/javascript-parse-error-on-u2028-unicode-character
private val UNICODE_2028_CHARS = charArrayOf('\\', 'u', '2', '0', '2', '8')
private val UNICODE_2029_CHARS = charArrayOf('\\', 'u', '2', '0', '2', '9')
private val HEX_DIGITS = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'values', 'b', 'c', 'd', 'e', 'f')
private val HEX_DIGITS = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f')


fun write(json: JsonValue): String =
Expand Down

0 comments on commit 93a5052

Please sign in to comment.