Convert java objects to JSON.