---
title: "How to send result back in JSON format in MVC"  
description: "How to send result back in JSON format in MVC"  
author: "Niraj Kumar Mishra"  
published: 2017-08-28  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/23294/how-to-send-result-back-in-json-format-in-mvc  
category: "asp.net mvc"  
tags: ["mvc"]  
reading_time: 1 minute  

---

# How to send result back in JSON format in MVC

In MVC, we have the **JsonResult** class by which we can return back data in JSON format. Below is a simple sample code which returns back a Customer object in JSON format using JsonResult.

```
public JsonResult getCustomer(){   Customer obj = new Customer();   obj.CustomerCode = "1001";   obj.CustomerName = "Shiv";   return
   Json(obj,JsonRequestBehavior.AllowGet);}
```

## Answers

### Answer by Niraj Kumar Mishra

In MVC, we have the **JsonResult** class by which we can return back data in JSON format. Below is a simple sample code which returns back a Customer object in JSON format using JsonResult.

```
public JsonResult getCustomer(){   Customer obj = new Customer();   obj.CustomerCode = "1001";   obj.CustomerName = "Shiv";   return
   Json(obj,JsonRequestBehavior.AllowGet);}
```


---

Original Source: https://www.mindstick.com/interview/23294/how-to-send-result-back-in-json-format-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
