-
Notifications
You must be signed in to change notification settings - Fork 525
Nested Objects #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
public static class A{
String name;
}
public static class B {
int prop;
A someA;
}
public void test_abc1() throws IOException {
JsonIterator.parse("[\n" +
" {\n" +
" \"someA\": {\n" +
" \"name\": \"test1\"\n" +
" },\n" +
" \"prop\": 2323\n" +
" },\n" +
" {\n" +
" \"someA\": {\n" +
" \"name\": \"test2\"\n" +
" },\n" +
" \"prop\": 2324\n" +
" }\n" +
"]").read(B[].class);
} It is not throwing exception on my machine. Please check the input codec. Only UTF-8 is supported. |
This is the json failing:
so probably its not about nested objects, but what is it? Its UTF8 and and jsonlint reports it as OK
|
I get the same error when "traficInKmh" property has String type in Java class but in JSON it has not quotes as in the example above |
@paulpolushkin if type is string, the JSON should have quotes. @anti43 can you provide your class definition? |
Hi, e.g expect string TYPE or null, but found INT property, head: 4944, peek: cInKmh" :) Dont you think String type should work for anything? |
Hi guys, I am also having a similar issue, however mine occurs specifically when a HashMap is involved - was wondering if it is somehow related. We feed the following string (which is actually produced by Jsoniter):
into the iterator and end up with the following error:
Any idea why this could happen? |
Actually to give you some background - the problem disappears when we set the HashMap key to be a String - the problem occurs when the key is an enum. |
Hi,
Is it possible to deserialize nested Objects?
Given classes
and json
is this supposed to work with
Joniterator.parse(json).read(B[].class)
?
I am getting error messages
com.jsoniter.spi.JsonException: readString: expect string or null, but 0, head: 444, peek: cInKmh":
Of course the class and json struct for real is much more complex, but the idea is the same.
What might be wrong here? With gson, it just worked with same json code.
The text was updated successfully, but these errors were encountered: