Hi,
I'm trying to write a simple precommit hook to modify a JSON object by
removing certain fields. The simplest way to do this, I figure, is to decode
the object's value with mochijson2, remove the fields I don't want,
re-encode it, and update the value.
What happens, though, is my object ends up somehow mangled. When I inspect
it via curl, it sort of looks like JSON, but characters like "{" and ":"
seem to be replaced with garbage.
For example, what should read "hostname":"www.google.com" looks like *
hostnamea"ja:la"mwww.google.coma"j*
To try to diagnose the issue, I reduced my hook to the simplest possible
case. I don't even modify the JSON, I just decode the object and re-encode
exactly the same value, but I still have the problem. The code is pasted
below
*precommit(RiakObject) ->*
* Value = riak_object:get_value(RiakObject),*
* {struct, TermList} = mochijson2:decode(Value),*
* riak_object:apply_updates(*
* riak_object:update_value(RiakObject, *
* mochijson2:encode({struct, TermList}))).
*
Can anybody point out what I'm doing wrong?
--
Greg
Clipboard <http://www.clipboard.com> is hiring<http://www.clipboard.com/jobs>
!
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com