---
title: "What type to give a JSON object"  
description: "What type to give a JSON object"  
author: "Manoj Bhatt"  
published: 2014-01-22  
updated: 2014-01-23  
canonical: https://www.mindstick.com/forum/1861/what-type-to-give-a-json-object  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# What type to give a JSON object

I have the following [form](https://www.mindstick.com/forum/6/multi-form-mfc-application)

```
 using (Ajax.BeginRouteForm(   ...                new
AjaxOptions                {                   
HttpMethod = "POST",                   
OnFailure = "OnFailure",                   
OnSuccess = "OnSuccess"                }))            {                ..,.            }
```

I implement the [OnSuccess](https://www.mindstick.com/forum/157899/what-is-the-role-of-the-onsuccess-and-onfailure-callbacks-in-an-ajax-request-in-mvc) [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) in a [TypeScript](https://www.mindstick.com/blog/303572/typescript-elevating-javascript-to-the-next-level-and-why) file. I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to make this function more TypeScripty. At the moment I have this

```
function OnSuccess(data: what type goes here?) {...// use data.SomeValue here...}
```

[Question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is what type shall I [say](https://answers.mindstick.com/qa/116645/a1-wreckers-reviews-what-do-customers-say) [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) is such that I can still somehow use data.SomeValue?

## Replies

### Reply by Pravesh Singh

Hi Manoj,\

The best way is with an interface, because you make an explicit assertion of the structure of the object returned and communicate very clearly what the callback expects.

```
export interface IOnSuccessArgs {    propertyA: string;    propertyB: number;}function OnSuccess(data: IOnSuccessArgs): void {   // ... data has propertyA and propertyB}
```


---

Original Source: https://www.mindstick.com/forum/1861/what-type-to-give-a-json-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
