Closed
Description
Hi,
I noticed a weird behaviour in parsing numbers (specifically, 0).
package it.cnr.istc.stlab;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import com.jsoniter.JsonIterator;
import com.jsoniter.any.Any;
import com.jsoniter.output.EncodingMode;
import com.jsoniter.output.JsonStream;
import com.jsoniter.spi.DecodingMode;
public class Test {
public static void main(String[] args) throws IOException {
JsonIterator ij = JsonIterator.parse(new byte[1024]);
ij.reset(new ByteArrayInputStream("[0]".getBytes()));
JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
ij.readArray();
Any o = ij.readAny();
System.out.println(o.toString());
System.out.println(o.toInt());
}
}
It throws an exception when it tries to transform o to integer.
Here is the stack trace
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by javassist.ClassPool (file:/Users/lgu/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of javassist.ClassPool
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
0
Exception in thread "main" com.jsoniter.spi.JsonException: readByte: no more to read, head: 1, peek: 0, buf: 0
at com.jsoniter.JsonIterator.reportError(JsonIterator.java:136)
at com.jsoniter.IterImplForStreaming.readByte(IterImplForStreaming.java:307)
at com.jsoniter.IterImplForStreaming.assertNotLeadingZero(IterImplForStreaming.java:619)
at com.jsoniter.IterImplForStreaming.readLong(IterImplForStreaming.java:596)
at com.jsoniter.IterImplNumber.readLong(IterImplNumber.java:96)
at com.jsoniter.JsonIterator.readLong(JsonIterator.java:185)
at com.jsoniter.any.LongLazyAny.fillCache(LongLazyAny.java:64)
at com.jsoniter.any.LongLazyAny.toInt(LongLazyAny.java:38)
at it.cnr.istc.stlab.Test.main(Test.java:22)
I'm not sure if I'm using the library correctly or not.
Metadata
Metadata
Assignees
Labels
No labels