Donate Share

Json-lib

Tracker: Feature Requests

5 Define reverse PropertyNameProcessor - ID: 1996152
Last Update: Comment added ( aalmiray )

As I understand it, a PropertyNameProcessor allows a JSON key to be matched
to a bean property name when deserializing JSON content to a bean.

However, it would be helpful to "close the circle", i.e. to have a way to
also map bean properties to JSON keys when generating JSON content from a
bean. Otherwise, round-trip (un)marshalling would be a problem.

Instead of defining a new interface, how about extending the existing
PropertyNameProcessor interface with a method that does the reverse
lookup?

(Use case: generate JSON from JAXB annotated classes, where fields have
annotations that specify a different name for the marshalled property.)


Peter Schubert ( w45p ) - 2008-06-17 14:08

5

Closed

None

aalmiray

Interface Improvements (example)

None

Public


Comments ( 4 )




Date: 2008-06-29 20:18
Sender: aalmirayProject Admin


FIXED.

deprecated get/setPropertyNameProcessor[Matcher]
added get/set[Java|Json]PropertyNameProcessor[Matcher]

PropertyNameProcessor interface remains unchanged.


Date: 2008-06-19 07:08
Sender: w45p


Yes, that would also be an elegant solution.
However, in my case I found it more convenient to have them both in the
same interface, for that would achieve a higher cohesion of the
PropertyNameProcessor implementation.

Either way, I'm looking forward to the next release!


Date: 2008-06-18 23:42
Sender: aalmirayProject Admin


Good idea. Actually it may not require another method but perhaps be
handled in the same way filters are. Either you register a filter for
JSON->Java parsing with JsonConfig.setJavaPropertyFilter(), or Java-> JSON
with JsonConfig.setJsonPropertyFilter()
We'll schedule it for the next release.


Date: 2008-06-18 08:18
Sender: w45p


To generalize, better support for deserialization customization is
required, to mirror existing serialization functionality. E.g.: value
processor, bean processor, etc.


Log in to comment.




Attached File

No Files Currently Attached

Changes ( 3 )

Field Old Value Date By
status_id Open 2008-06-29 20:18 aalmiray
close_date - 2008-06-29 20:18 aalmiray
assigned_to nobody 2008-06-18 23:42 aalmiray