Re: Issue 386 in google-gson: Fail if a JSON object has a duplicated property name

1 view
Skip to first unread message

googl...@googlecode.com

unread,
Dec 29, 2011, 12:41:51 AM12/29/11
to google-gson...@googlegroups.com
Updates:
Summary: Fail if a JSON object has a duplicated property name
Labels: -Priority-Medium Priority-High

Comment #1 on issue 386 by limpbiz...@gmail.com: Fail if a JSON object has
a duplicated property name
http://code.google.com/p/google-gson/issues/detail?id=386

This is a great idea but it comes at a high cost in performance. We'd need
to track all the names seen at all nesting levels.

googl...@googlecode.com

unread,
Jun 18, 2015, 8:55:37 AM6/18/15
to google-gson...@googlegroups.com

Comment #2 on issue 386 by mihai.ch...@gmail.com: Fail if a JSON object has
a duplicated property name
https://code.google.com/p/google-gson/issues/detail?id=386

Couldn't you just check if the attribute already has a value, and if it
does throw an exception? I don't know the details of the implementation,
but I would add something like this:

if (field.get(value) != null) {
throw new DuplicateValueException("Duplicate attribute: " +
field.getName());
}

in ReflectiveTypeAdapterFactory.createBoundField before

field.set(value, fieldValue)

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages