MCPcopy
hub / github.com/OpenTSDB/opentsdb / serializeToJSONPString

Method serializeToJSONPString

src/utils/JSON.java:311–322  ·  view source on GitHub ↗

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 @throws IllegalArg

(final String callback,
      final Object object)

Source from the content-addressed store, hash-verified

309 * @throws JSONException if the object could not be serialized
310 */
311 public static final String serializeToJSONPString(final String callback,
312 final Object object) {
313 if (callback == null || callback.isEmpty())
314 throw new IllegalArgumentException("Missing callback name");
315 if (object == null)
316 throw new IllegalArgumentException("Object was null");
317 try {
318 return jsonMapper.writeValueAsString(new JSONPObject(callback, object));
319 } catch (JsonProcessingException e) {
320 throw new JSONException(e);
321 }
322 }
323
324 /**
325 * Serializes the given object and wraps it in a callback function

Calls 1

isEmptyMethod · 0.80