@@ -156,7 +156,7 @@ object Json {
156
156
fun writeJson (array : ByteArray? , builder : JsonStringBuilder ) {
157
157
if (array == null ) {
158
158
builder.append(NULL )
159
- } else if (array.size == 0 ) {
159
+ } else if (array.isEmpty() ) {
160
160
builder.append(" []" )
161
161
} else {
162
162
builder.append(' [' ).incIndent().newLine()
@@ -173,7 +173,7 @@ object Json {
173
173
fun writeJson (array : ShortArray? , builder : JsonStringBuilder ) {
174
174
if (array == null ) {
175
175
builder.append(NULL )
176
- } else if (array.size == 0 ) {
176
+ } else if (array.isEmpty() ) {
177
177
builder.append(" []" )
178
178
} else {
179
179
builder.append(' [' ).incIndent().newLine()
@@ -190,7 +190,7 @@ object Json {
190
190
fun writeJson (array : IntArray? , builder : JsonStringBuilder ) {
191
191
if (array == null ) {
192
192
builder.append(NULL )
193
- } else if (array.size == 0 ) {
193
+ } else if (array.isEmpty() ) {
194
194
builder.append(" []" )
195
195
} else {
196
196
builder.append(' [' ).incIndent().newLine()
@@ -207,7 +207,7 @@ object Json {
207
207
fun writeJson (array : LongArray? , builder : JsonStringBuilder ) {
208
208
if (array == null ) {
209
209
builder.append(NULL )
210
- } else if (array.size == 0 ) {
210
+ } else if (array.isEmpty() ) {
211
211
builder.append(" []" )
212
212
} else {
213
213
builder.append(' [' ).incIndent().newLine()
@@ -224,7 +224,7 @@ object Json {
224
224
fun writeJson (array : FloatArray? , builder : JsonStringBuilder ) {
225
225
if (array == null ) {
226
226
builder.append(NULL )
227
- } else if (array.size == 0 ) {
227
+ } else if (array.isEmpty() ) {
228
228
builder.append(" []" )
229
229
} else {
230
230
builder.append(' [' ).incIndent().newLine()
@@ -241,7 +241,7 @@ object Json {
241
241
fun writeJson (array : DoubleArray? , builder : JsonStringBuilder ) {
242
242
if (array == null ) {
243
243
builder.append(NULL )
244
- } else if (array.size == 0 ) {
244
+ } else if (array.isEmpty() ) {
245
245
builder.append(" []" )
246
246
} else {
247
247
builder.append(' [' ).incIndent().newLine()
@@ -258,7 +258,7 @@ object Json {
258
258
fun writeJson (array : BooleanArray? , builder : JsonStringBuilder ) {
259
259
if (array == null ) {
260
260
builder.append(NULL )
261
- } else if (array.size == 0 ) {
261
+ } else if (array.isEmpty() ) {
262
262
builder.append(" []" )
263
263
} else {
264
264
builder.append(' [' ).incIndent().newLine()
@@ -275,7 +275,7 @@ object Json {
275
275
fun writeJson (array : CharArray? , builder : JsonStringBuilder ) {
276
276
if (array == null ) {
277
277
builder.append(NULL )
278
- } else if (array.size == 0 ) {
278
+ } else if (array.isEmpty() ) {
279
279
builder.append(" []" )
280
280
} else {
281
281
builder.append(' [' ).incIndent().newLine()
@@ -292,7 +292,7 @@ object Json {
292
292
fun writeJson (array : Array <Any ?>? , builder : JsonStringBuilder ) {
293
293
if (array == null ) {
294
294
builder.append(NULL )
295
- } else if (array.size == 0 ) {
295
+ } else if (array.isEmpty() ) {
296
296
builder.append(" []" )
297
297
} else {
298
298
builder.append(' [' ).newLine().incIndent().fillSpaces()
@@ -314,7 +314,7 @@ object Json {
314
314
}
315
315
val iter: Iterator <* > = map.entries.iterator()
316
316
builder.append(' {' ).incIndent()
317
- if (! map.isEmpty ()) {
317
+ if (map.isNotEmpty ()) {
318
318
builder.newLine()
319
319
}
320
320
while (iter.hasNext()) {
@@ -366,6 +366,7 @@ object Json {
366
366
}
367
367
}
368
368
369
+ @Suppress(" UNCHECKED_CAST" )
369
370
private fun doWriteJson (value : Any , builder : JsonStringBuilder ) {
370
371
if (value is ByteArray ) {
371
372
JsonArray .writeJson(value, builder)
@@ -536,7 +537,7 @@ object Json {
536
537
readRequiredChar(' r' )
537
538
readRequiredChar(' u' )
538
539
readRequiredChar(' e' )
539
- return java.lang. Boolean . TRUE
540
+ return true
540
541
}
541
542
542
543
private fun readFalse (): Boolean {
@@ -545,7 +546,7 @@ object Json {
545
546
readRequiredChar(' l' )
546
547
readRequiredChar(' s' )
547
548
readRequiredChar(' e' )
548
- return java.lang. Boolean . FALSE
549
+ return false
549
550
}
550
551
551
552
private fun readRequiredChar (ch : Char ) {
@@ -626,8 +627,7 @@ object Json {
626
627
readFraction()
627
628
readExponent()
628
629
val number = endCapture()
629
- val result: Number
630
- result = if (number.contains(" ." ) || number.contains(" e" ) || number.contains(" E" )) {
630
+ val result: Number = if (number.contains(" ." ) || number.contains(" e" ) || number.contains(" E" )) {
631
631
if (number.length > 9
632
632
|| number.contains(" ." ) && number.length - number.lastIndexOf(' .' ) > 2
633
633
&& number[number.length - 1 ] == ' 0'
@@ -724,7 +724,7 @@ object Json {
724
724
private fun endCapture (): String {
725
725
val end = if (current == - 1 ) index else index - 1
726
726
val captured: String
727
- if (captureBuffer!! .length > 0 ) {
727
+ if (captureBuffer!! .isNotEmpty() ) {
728
728
captureBuffer!! .append(json, captureStart, end)
729
729
captured = captureBuffer.toString()
730
730
captureBuffer!! .setLength(0 )
@@ -749,12 +749,12 @@ object Json {
749
749
}
750
750
751
751
private val isWhiteSpace: Boolean
752
- private get() = current == ' ' .code || current == ' \t ' .code || current == ' \n ' .code || current == ' \r ' .code
752
+ get() = current == ' ' .code || current == ' \t ' .code || current == ' \n ' .code || current == ' \r ' .code
753
753
private val isDigit: Boolean
754
- private get() = current >= ' 0' .code && current <= ' 9' .code
754
+ get() = current >= ' 0' .code && current <= ' 9' .code
755
755
private val isHexDigit: Boolean
756
- private get() = isDigit || current >= ' a' .code && current <= ' f' .code || current >= ' A' .code && current <= ' F' .code
756
+ get() = isDigit || current >= ' a' .code && current <= ' f' .code || current >= ' A' .code && current <= ' F' .code
757
757
private val isEndOfText: Boolean
758
- private get() = current == - 1
758
+ get() = current == - 1
759
759
}
760
760
}
0 commit comments