lib/json: fix json serialization to play well with other engines