List of usage examples for com.fasterxml.jackson.databind.util JSONPObject JSONPObject
public JSONPObject(String function, Object value)
From source file:io.seldon.api.controller.ActionsController.java
private JSONPObject asCallback(String callbackName, Object valueObject) { return new JSONPObject(callbackName, valueObject); }
From source file:com.heliosapm.mws.server.net.json.JSON.java
/** * Serializes the given object and wraps it in a callback function * i.e. <callback>(<json>) * Note: This will not append a trailing semicolon * @param callback The name of the Javascript callback to prepend * @param object The object to serialize * @return A JSONP formatted string// w w w. j a v a 2s .com * @throws IllegalArgumentException if the callback method name was missing * or object was null * @throws JSONException if the object could not be serialized * @throws IOException Thrown when there was an issue reading the object */ @SuppressWarnings("javadoc") public static final String serializeToJSONPString(final String callback, final Object object) { if (callback == null || callback.isEmpty()) throw new IllegalArgumentException("Missing callback name"); if (object == null) throw new IllegalArgumentException("Object was null"); try { return jsonMapper.writeValueAsString(new JSONPObject(callback, object)); } catch (JsonProcessingException e) { throw new JSONException(e); } }
From source file:com.heliosapm.mws.server.net.json.JSON.java
/** * Serializes the given object and wraps it in a callback function * i.e. <callback>(<json>) * Note: This will not append a trailing semicolon * @param callback The name of the Javascript callback to prepend * @param object The object to serialize * @return A JSONP formatted byte array//from ww w . j av a2 s. c om * @throws IllegalArgumentException if the callback method name was missing * or object was null * @throws JSONException if the object could not be serialized * @throws IOException Thrown when there was an issue reading the object */ @SuppressWarnings("javadoc") public static final byte[] serializeToJSONPBytes(final String callback, final Object object) { if (callback == null || callback.isEmpty()) throw new IllegalArgumentException("Missing callback name"); if (object == null) throw new IllegalArgumentException("Object was null"); try { return jsonMapper.writeValueAsBytes(new JSONPObject(callback, object)); } catch (JsonProcessingException e) { throw new JSONException(e); } }
From source file:com.heliosapm.tsdblite.json.JSON.java
/** * Serializes the given object and wraps it in a callback function * i.e. <callback>(<json>) * Note: This will not append a trailing semicolon * @param callback The name of the Javascript callback to prepend * @param object The object to serialize * @return A JSONP formatted string//from w w w . j a v a2s . co m * @throws IllegalArgumentException if the callback method name was missing * or object was null * @throws JSONException if the object could not be serialized */ public static final String serializeToJSONPString(final String callback, final Object object) { if (callback == null || callback.isEmpty()) throw new IllegalArgumentException("Missing callback name"); if (object == null) throw new IllegalArgumentException("Object was null"); try { return jsonMapper.writeValueAsString(new JSONPObject(callback, object)); } catch (JsonProcessingException e) { throw new JSONException(e); } }
From source file:com.heliosapm.tsdblite.json.JSON.java
/** * Serializes the given object and wraps it in a callback function * i.e. <callback>(<json>) * Note: This will not append a trailing semicolon * @param callback The name of the Javascript callback to prepend * @param object The object to serialize * @return A JSONP formatted byte array/*w w w. ja v a 2 s . co m*/ * @throws IllegalArgumentException if the callback method name was missing * or object was null * @throws JSONException if the object could not be serialized * @throws IOException Thrown when there was an issue reading the object */ public static final byte[] serializeToJSONPBytes(final String callback, final Object object) { if (callback == null || callback.isEmpty()) throw new IllegalArgumentException("Missing callback name"); if (object == null) throw new IllegalArgumentException("Object was null"); try { return jsonMapper.writeValueAsBytes(new JSONPObject(callback, object)); } catch (JsonProcessingException e) { throw new JSONException(e); } }
From source file:com.glaf.activiti.web.rest.ActivitiResource.java
@GET @Path("highlighted") public JSONPObject highlighted(@QueryParam("processInstanceId") String processInstanceId, @QueryParam("callback") String callback) { init();/*from w w w .j ava 2s. c om*/ this.processInstanceId = processInstanceId; ObjectNode highlighted = getHighlighted(); return new JSONPObject(callback, highlighted); }
From source file:org.emonocot.portal.controller.SearchController.java
@RequestMapping(value = "/search", method = RequestMethod.GET, produces = "application/javascript") public ResponseEntity<JSONPObject> searchAPIJSONP(@RequestParam(value = "query", required = false) String query, @RequestParam(value = "limit", required = false, defaultValue = "24") Integer limit, @RequestParam(value = "start", required = false, defaultValue = "0") Integer start, @RequestParam(value = "facet", required = false) @FacetRequestFormat List<FacetRequest> facets, @RequestParam(value = "x1", required = false) Double x1, @RequestParam(value = "y1", required = false) Double y1, @RequestParam(value = "x2", required = false) Double x2, @RequestParam(value = "y2", required = false) Double y2, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "callback", required = true) String callback, Model model) throws SolrServerException { spatial(query, x1, y1, x2, y2, null, limit, start, facets, sort, null, model); return new ResponseEntity<JSONPObject>(new JSONPObject(callback, (Page) model.asMap().get("result")), HttpStatus.OK);//from ww w . ja v a 2 s . c o m }