`

return HttpResponseMessage with ObjectContent Json Type

 
阅读更多
public async Task<HttpResponseMessage> Register(AllenRegistration model){}

1.Will return 400 Error 
  return Request.CreateResponse(HttpStatusCode.BadRequest);
2.Will return Json Type like   {"return1":"A","returnB"L:"B"}
return new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent<object>(new
                {
                    return1="A",
                    return2="B"
                }, Configuration.Formatters.JsonFormatter)
            };
        }
} 

 

分享到:
评论

相关推荐

    java jsonto对象互转

    public static String objectToJson(Object javaObj, String dataFormat) { JSONObject json; JsonConfig jsonConfig = configJson(dataFormat); json = JSONObject.fromObject(javaObj, jsonConfig); return ...

    java解析json

    public static Object jsonToBean(String jsonString, Class cla, Map map) { JSONObject jsonObj = null; try { setDateFormat2Java(); jsonObj = JSONObject.fromObject(jsonString); } catch ...

    Json字符串和对象的转换.txt

    public static String toJson(Object obj) { String result=""; try { result = MAPPER.writeValueAsString(obj); } catch (JsonProcessingException e) { e.printStackTrace(); //将编译...

    a portfolio selection problem with type-2 fuzzy return.pdf

    a portfolio selection problem with type-2 fuzzy return.pdf a portfolio selection problem with type-2 fuzzy return.pdf a portfolio selection problem with type-2 fuzzy return.pdf

    Java 开发所需json的jar包,转json格式

    Java 开发所需json的jar包,项目对象转json格式, Map,Object&gt; map=HashMap,Object&gt;(); map.put("sex","man"); toJson(map); /** * 将得到的数据以json格式进行输出,如果对象不存在则输出空字符串 * * @param ...

    VC通过Http协议Get或Post方式与WebService通信,解析返回的Json

    iMyHttp.RequestJsonInfo((LPCTSTR)m_strUrl,Hr_Post,"Content-Type:application/x-www-form-urlencoded",strData,m_nTimeOut); if (!MyHttp.ParseJsonInfo()) { return OutPutFailInfo(MyHttp.GetErrInfo()); ...

    Laravel自定义 封装便捷返回Json数据格式的引用方法

    return response()-&gt;json(['status' =&gt; 'success','code' =&gt; 200,'message' =&gt; '关注成功']); return response()-&gt;json(['status' =&gt; 'fail','code' =&gt; 500,'error' =&gt; '关注失败',]); 基类控制器 &lt;?php ...

    Parsing JSON in Swift

    Parsing JSON in Swift will teach you to harness the ...You'll go from fighting an uphill battle against an uncooperative compiler to having a JSON parser that's proven to be stable with automated tests.

    Json解析ParsreTools.zip

    Object object = new Object(); if (type.equals("int")) { object = jsonObject2.getInt(varName[i]); } else if (type.equals("double")) { object = jsonObject2.getDouble(varName[i]); ...

    json的介绍 以及 json2.js的用法

    var myJSONText = JSON.stringify(myObject, function (key, value) { return value; }); 值在JSON中不代表任何内容,函数与未定义(undefined)被排除在外。 不能确定的数量将被替换为null。为了替代其它的值,可以...

    json.jar包

    1. List集合转换成json代码 List list = newArrayList(); list.add( "first" ); list.add( "second" ); ...JSONArray jsonArray2 =JSONArray....JSONArray jsonArray3 =JSONArray.fromObject("['json','is','easy']" );

    json.js_json2.js

    This file creates a global JSON object containing two methods: stringify and parse. JSON.stringify(value, replacer, space) value any JavaScript value, usually an object or array. replacer an ...

    JsonViewer.rar

    json 解析pas单元和json查看工具。一下是版本 * v1.2 * + support of currency data type * + right trim unquoted string * + read Unicode Files and streams (Litle Endian with BOM) * + Fix bug on ...

    json2.js javascript

    json2.js 将对象JSON化: JSON.stringify(value, [replacer], [space]) 例子: $(document).ready(function () { $("#update").click(function () { var employee = { EmployeeName: $("#EmployeeName").val(),...

    JSON替代λJSON.zip

    // `newPlayer` is a function and couldn't be serialized with JSON.function newPlayer(name){ return {  name : name,  hp : 12,  atk : 5,  def : 5,  inventory : []} }; ...

    UE4json插件

    UE4json插件,可以打包到web服务器并且返回数据

    对python中Json与object转化的方法详解

    一个python object无法直接与json转化,只能先将对象转化成dictionary,再转化成json;对json,也只能先转换成dictionary,再转化成object,通过实践,源码如下: import json class user: def __init__(self, ...

    json的解析

    该小项目完整全面整理了java解析json各中写法,以及json的生成、遍历。 该项目收集整理json所需的jar包,使用文档。 /** * json的生成、遍历 */ import java.util.*; import net.sf.json.JSONArray; import ...

    json-schema-validator-master JsonValidator

    return literal("true") || literal("false") || literal("null") || string() || number() || object() || array(); } private boolean literal(String text) { CharacterIterator ci = new ...

    C#实现String类型和json之间的相互转换功能示例

    本文实例讲述了C#实现String类型和json之间的相互转换功能。分享给大家供大家参考,具体如下: ...public static object JsonToObject(string jsonString,object obj) { return JavaScriptConver

Global site tag (gtag.js) - Google Analytics