java - Jackson annotation or method to URL encode/decode during serialization? -
java - Jackson annotation or method to URL encode/decode during serialization? -
i'm wondering if there's easy way url encode/decode when serializing , deserializing objects in jackson. reason ensure incoming fields going indexed in riak not contain illegal characters.
for illustration have next class (in scala):
case class client( @(jsonproperty@field)("guid") @(riakkey@field) val guid: string, @(jsonproperty@field)("name") @(riakindex@field)(name = "name") val name: string, @(jsonproperty@field)("address") val address: string, @(jsonproperty@field)("contact") val contact: string, @(jsonproperty@field)("phone") @(riakindex@field)(name = "phone") val phone: string, @(jsonproperty@field)("suspended") val suspended: boolean=false, @(jsonproperty@field)("created") val created: date=now, @(jsonproperty@field)("updated") val updated: date=now ) so on name field, might have space between name part of riak index. produce next error when go store json object in riak:
caused by: java.net.urisyntaxexception: illegal character in path @ index 82: http://db2.3tierlogic.com:8098:8098/buckets/accounts-client/index/name_bin/calgary flames @ java.net.uri$parser.fail(uri.java:2810) @ java.net.uri$parser.checkchars(uri.java:2983) @ java.net.uri$parser.parsehierarchical(uri.java:3067) @ java.net.uri$parser.parse(uri.java:3015) @ java.net.uri.<init>(uri.java:577) @ java.net.uri.create(uri.java:839) ... 105 more is there annotation or simple method of url encoding , decoding field on fly?
the easy way specify serializer/deserializer use
@jsonserialize(using=classof[yourserializer]) @jsondeerialize(using=classof[yourdeserializer]) var customencodedproperty: string = _ java scala jackson riak
Comments
Post a Comment