0

If I have a class say

class A
{
String field1
String field2
String field3
} 

And I have another class B that contains the following

{
String field1
String field2
} 

There is a byte array of key value pairs, [#maps to field1, #maps to field2] How can I using gson map the byte array to the fields in class A without creating a class B that contains the exact number of fields in the map ?

Can I exclude field3 while deserialization ? How do I do that ?

0

1 Answer 1

1

The best approach would be to mark field3 as

transient

Gson will not populate (deserialize) its value from the string.. Alternatively, you can use a custom deserializer implementation which would selectively deserialize things. Here is a link for this kind of solution.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.