Open Ashok-Varma opened 6 years ago
Thanks.
This is a tricky case because JSON maps only allow strings as keys. The enum instances are easily represented as strings, but StandardJsonPlugin
doesn't know that.
I'll try to take a look at some point, maybe there's something we can do better here.
By the way, I don't think you need the BuiltValueEnumConst
annotations.
@davidmorgan i didn't use BuiltValueEnumConst
in the beginning. But i thought that might solve the issue. So gave them a try, almost tried all possible variations.
Is there any walk around to this problem.
The best workaround I can think of is to use BuiltMap<String, double>
and to use Allowance.name
and Allowance.valueOf
to convert to and from String
. But that's not a great solution. I'll try to have a look this week or next.
Hai @davidmorgan , Any update on this issue ??
Sorry, I've been pretty slow in getting to this. Hoping to take a look soon; ~next week.
Hai @davidmorgan, many people are still waiting for this fix.
Sorry for that. I have an idea for a fix, but unfortunately it's quite complicated; it involves changing the serializer interfaces so a serializer declares if it's always going to return a string. (Currently we have two types of serializer: primitive and structured. We would instead have three, string, primitive and structured).
I expect this will happen at some point but I'm afraid it's hard to predict when.
Hi @davidmorgan , thank you for your effort. Did you have time to look at this issue?
I don't have any ETA for this, unfortunately; it's a complex fix. I do hope to get to it at some point.
I took a look at this; it looks possible by:
But, it's still breaking to change the wire format; so it'll have to be an option on StandardJsonSerializer.
I think it's too big a feature for me to get to this time around--going to look at more smaller fixes first.
I have a variableof type BuiltMap<T extends EnumClass, double> in my model. serialize and deserialize of this model to json is failing
for this variable in json the library is expecting the key to surround two quotes.
on serialization of sample model. i get this
{"basic":1.0,"allowances":{"\"MEDICAL_REIMBURSEMENT\"":2.0}}
as output which is invalid json. and also deserialization fails unless i give two quotesSample model