Comments (9)
Does this work on regular Jackson ?
I never tried to support 2D arrays so it's not surprising it does not work :p
As a workaround, can you try to create your own deserializer for this ?
Using the documentation here : https://github.com/nmorel/gwt-jackson/wiki/Custom-serializers-and-deserializers
I did a quick test, it seems to work.
In your configuration, you add this :
type( String[][].class ).deserializer( MyString2DArrayDeserializer.class );
And the deserializer can look like this :
public class MyString2DArrayDeserializer extends JsonDeserializer<String[][]> {
@Override
protected String[][] doDeserialize( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) {
List<List<String>> res = new ArrayList<List<String>>();
reader.beginArray();
while ( JsonToken.END_ARRAY != reader.peek() ) {
List<String> list = new ArrayList<String>();
reader.beginArray();
while ( JsonToken.END_ARRAY != reader.peek() ) {
list.add( reader.nextString() );
}
reader.endArray();
res.add( list );
}
reader.endArray();
if ( res.isEmpty() ) {
return new String[0][0];
}
String[][] trueRes = new String[res.size()][res.get( 0 ).size()];
int i = 0;
for ( List<String> list : res ) {
int j = 0;
for ( String s : list ) {
trueRes[i][j++] = s;
}
i++;
}
return trueRes;
}
}
from gwt-jackson.
Thanks for the very prompt response! I'll give this a try.
I can confirm 2D arrays work in regular Jackson, 1.9.7 and 2.3.2
from gwt-jackson.
Hi - I had a problem deserializing nulls into a 2D string array. I'm not sure if the bug is particular to 2D arrays or a general issue, but I can load the same data in Jackson just fine.
java.lang.IllegalStateException: Expected a string but was NULL at line 1 column 154
The line/column reference above is talking about the source JSON data where the first null occurs.
from gwt-jackson.
Instead of reader.nextString()
, try StringJsonDeserializer.getInstance().deserialize(reader, ctx, params)
. It will take care of the null value.
Or wait for the next release that should come soon. (at least the snapshot)
from gwt-jackson.
The 0.4.1-SNAPSHOT
snapshot is available. Can you give it a try ?
If it works for you, I'll release the 0.4.1
.
from gwt-jackson.
Thanks - I should get a chance to try this tonight or tomorrow.
from gwt-jackson.
Hi,
I just had the chance to try 0.4.1-SNAPSHOT, and I'm still getting the same error I'm afraid.
GwtApplication: exception: Couldn't deserialize map [newGfxMap] java.lang.IllegalStateException: Expected a string but was NULL at line 1 column 154
Data snippet:
{"name":"New Map","graphicsPackId":"mxxxxxxGfxPack.json","tileIds":[["1","19","19","19","19","19","19","19","19","19","19","19","19","19","19"],["1",null,null,null,null...
from gwt-jackson.
Did you remove the workaround with the custom deserializer ?
And you can try the 0.5.0
from gwt-jackson.
Ha - you pre-empted my absent-mindedness! I will remove that and try again :)
from gwt-jackson.
Related Issues (20)
- No source code is available for type com.fasterxml.jackson.databind.ObjectMapper; did you forget to inherit a required module? HOT 3
- Support for java.util.Optional HOT 1
- Expected a string but was BEGIN_OBJECT at line 1 column 2 HOT 1
- Please REVERT the dependency on Jackson 2.9.*, Jackson 2.9.* is NOT compatible with GWT. HOT 2
- Support for @JsonCreator(mode = Mode.DELEGATING)
- Custom deserializer compilation error
- Getter returning Optional<T> of nullable T causing compilation error HOT 2
- GWT 2.6.1 + GwtJackson 0.15.3 HOT 3
- JsonSerializationContext.Builder override not working as expected
- Error:GWT Compiler: No source code is available for type com.fasterxml.jackson.annotation.JsonTypeInfo.As; did you forget to inherit a required module?
- JsonTypeInfo defaultImpl attribute not working HOT 1
- Update jackson dependency to 2.9.8
- Update javapoet dependency to 1.11.1
- Support for JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE
- Annotations on Java8 default interface are ignored HOT 1
- Can't figure out the stackoverflow I am getting
- More (de)serialization customization (JsonFilter or equivalent)
- Double.NaN / NEGATIVE_INFINITY / POSITIVE_INFINITY - Numeric values must be finite, but was
- Many compile problems
- I want to deserialize a property with any type of value.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwt-jackson.