简体   繁体   中英

return clean json Actionresult controller

I have this acion

public async Task<ActionResult> Get(short Y, string r)
    {
        var items = await _tRepository.Get(Y, r);
        return Ok(items);
    }

the problem is that json i send to the client contains the parameter "items"

{"items":[{"k":9995,"y":"yyy"},{"Y":9934,"y":"xxx"}]}

i want to send the client clean json

It depend on your items type and if you need to return just array or list without items property, you must use return Ok(items.Items);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM