---
title: "Deserialize JSON string to Dictionary<string,object>"  
description: "Deserialize JSON string to Dictionary<string,object>"  
author: "Anonymous User"  
published: 2013-12-23  
updated: 2013-12-23  
canonical: https://www.mindstick.com/forum/1818/deserialize-json-string-to-dictionary-string-object  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Deserialize JSON string to Dictionary<string,object>

I have this [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp):

[{ "processLevel" : "1" , "segments" : [{ "min" : "0", "[max](https://www.mindstick.com/articles/1155/count-max-min-function-in-excel)" : "600" }] }]

I'm deserializing the object:

object [json](https://www.mindstick.com/forum/34446/convert-json-string-to-object) = jsonSerializer.DeserializeObject(jsonString);

The object looks like:

object[0] = Key: "processLevel", [Value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages): "1"

object[1] = Key: "segments", Value: ...

And [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to create a [dictionary](https://www.mindstick.com/articles/1500/hashtable-and-dictionary-in-c-sharp):

Dictionary<string, object> dic = json as Dictionary<string, object>;

but dic gets null.

What can be the issue ?

## Replies

### Reply by Pravesh Singh

Hi Chintoo,

The problem is that the object is not of type Dictionary<string,object> or a compatible type, thus you can't cast directly. I would create a custom object and use Deserialize.

public class DeserializedObject{

public string processLevel{get;set;}

public object segments{get;set}

}

IEnumerable<DeserializedObject> object=jsonSerializer.Deserialize<IEnumerable<DeserializedObject>>(json)


---

Original Source: https://www.mindstick.com/forum/1818/deserialize-json-string-to-dictionary-string-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
