Example usage for com.fasterxml.jackson.databind.util JSONPObject JSONPObject

List of usage examples for com.fasterxml.jackson.databind.util JSONPObject JSONPObject

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.util JSONPObject JSONPObject.

Prototype

public JSONPObject(String function, Object value) 

Source Link

Usage

From source file:com.xyxy.platform.examples.showcase.demos.web.MashupServerController.java

@RequestMapping(value = "/web/mashup2", produces = MediaTypes.JAVASCRIPT_UTF_8)
@ResponseBody//w w w.jav  a 2 s .  c o  m
public JSONPObject mashup2(@RequestParam(DEFAULT_JQUERY_JSONP_CALLBACK_PARM_NAME) String callbackName) {

    // ??JSON.
    Map<String, String> map = Collections.singletonMap("content", "<p>?</p>");

    // .
    return new JSONPObject(callbackName, map);
}

From source file:io.seldon.api.interceptor.JavascriptScopeInterceptor.java

@Override
protected void exceptionResponse(HttpServletRequest request, HttpServletResponse response, APIException e)
        throws IOException {
    ErrorBean bean = new ErrorBean(e);
    String jsonpCallback = request.getParameter("jsonpCallback");
    final ObjectMapper objectMapper = new ObjectMapper();

    response.setContentType("application/json");

    if (StringUtils.isBlank(jsonpCallback)) {
        objectMapper.writeValue(response.getOutputStream(), bean);
    } else {/*from   w ww .jav a  2s. co m*/
        JSONPObject jsonp = new JSONPObject(jsonpCallback, bean);
        objectMapper.writeValue(response.getOutputStream(), jsonp);
    }
}

From source file:ninja.template.TemplateEngineJsonP.java

@Override
public void invoke(Context context, Result result) {
    ResponseStreams responseStreams = context.finalizeHeaders(result);
    String callback = getCallbackName(context);
    try (OutputStream outputStream = responseStreams.getOutputStream()) {
        objectMapper.writeValue(outputStream, new JSONPObject(callback, result.getRenderable()));
    } catch (IOException e) {
        logger.error("Error while rendering jsonp.", e);
    }//from  w w w  . ja va2  s.  co m
}

From source file:com.glaf.activiti.web.rest.ActivitiResource.java

@GET
@Path("diagram")
public JSONPObject diagram(@QueryParam("processDefinitionId") String processDefinitionId,
        @QueryParam("processInstanceId") String processInstanceId, @QueryParam("callback") String callback) {
    init();//  w  ww . j  a  v  a  2s . c o  m
    this.processDefinitionId = processDefinitionId;
    this.processInstanceId = processInstanceId;

    ObjectNode diagram = getDiagram();

    return new JSONPObject(callback, diagram);
}

From source file:com.cnksi.core.tools.mapper.JsonMapper.java

/**
 * JSONP?.
 */
public String toJsonP(String functionName, Object object) {

    return toJson(new JSONPObject(functionName, object));
}

From source file:cn.cdwx.jpa.utils.mapper.JsonMapper.java

/**
 * JSONP?.
 */
public String toJsonP(String functionName, Object object) {
    return toJson(new JSONPObject(functionName, object));
}

From source file:$.JsonMapper.java

/**
     * JSONP?.//from  www .  j a va2s  .c  om
     */
    public String toJsonP(String functionName, Object object) {
        return toJson(new JSONPObject(functionName, object));
    }

From source file:io.werval.modules.json.JacksonJSON.java

@Override
public String toJSONPString(String callbackFunctionName, Object object) {
    try {//ww w .java  2s.  c om
        return mapper.writeValueAsString(new JSONPObject(callbackFunctionName, object));
    } catch (JsonProcessingException ex) {
        throw new JsonPluginException(ex);
    }
}

From source file:io.werval.modules.json.JacksonJSON.java

@Override
public String toJSONPString(String callbackFunctionName, Object object, Class<?> jsonView) {
    try {/*from   w w  w  .j  av  a  2s .  c o m*/
        return mapper.writeValueAsString(new JSONPObject(callbackFunctionName, toNode(object, jsonView)));
    } catch (JsonProcessingException ex) {
        throw new JsonPluginException(ex);
    }
}

From source file:com.github.dactiv.common.bundle.JacksonBundle.java

/**
 * ??JSONP?// w  w w .  ja v  a2  s  . c o m
 * 
 * @param function jsonp??
 * @param target ?jsonp
 */
public String toJsonP(String function, Object target) {
    return toJson(new JSONPObject(function, target));
}