---
title: "JsonConvert string to integer about digit grouping symbol"  
description: "JsonConvert string to integer about digit grouping symbol"  
author: "Dag Hammarskjold"  
published: 2013-06-20  
updated: 2013-06-20  
canonical: https://www.mindstick.com/forum/1244/jsonconvert-string-to-integer-about-digit-grouping-symbol  
category: "json"  
tags: ["json"]  
reading_time: 2 minutes  

---

# JsonConvert string to integer about digit grouping symbol

Hi Guys,\
I get an error that is 'Could not [convert string](https://www.mindstick.com/forum/159139/convert-string-to-date-in-oracle-sql) to [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer): 3.500. Path 'Quantity'' while json converting to object.\
json :**\****{"ProductCalcKey":"xxx","PaperType":"1","Quantity":"3.500"}****object:****\****[public](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) class UnitPrice****{** **public int UnitPriceId { get; set; }** **public int QuantityMin { get; set; }** **public int QuantityMax { get; set; }** **public [decimal](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) Price { get; set; }** **public string ProductCalcKey { get; set; }** **public PaperType? PaperType { get; set; }** **public int Quantity { get; set; }****}**I am using the following method.**\****protected object FromJsonToObject(Type t)****{** **Context.Request.InputStream.Position = 0;** **string json;** **using (var reader = new [StreamReader](https://www.mindstick.com/forum/161576/explain-the-difference-between-streamreader-and-file-readalllines)(Context.Request.InputStream))** **{** **json = reader.ReadToEnd();** **}****\** // todo: string to integer such as '222.222.222' **return [JsonConvert.DeserializeObject](https://www.mindstick.com/forum/161290/how-does-jsonconvert-deserializeobject-work-in-c-sharp)(json, t, new IsoDateTimeConverter());****}****\**How can I [solve this problem](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem) without touching jsontext ?

## Replies

### Reply by AVADHESH PATEL

Hi,\
I have solved the [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) in this way.\

```
public class FormatConverter : JsonConverter{    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)    {        throw new NotImplementedException();    }    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)    {        if (objectType == typeof(int))        {            return Convert.ToInt32(reader.Value.ToString().Replace(".", string.Empty));        }        return reader.Value;    }    public override bool CanConvert(Type objectType)    {        return objectType == typeof(int);    }}[Test]public void ConvertJson(){    const string Json = "{\"ProductCalcKey\":\"xxx\",\"PaperType\":\"1\",\"Quantity\":\"3.500\"}";    var o = (UnitPrice)JsonConvert.DeserializeObject(Json, typeof(UnitPrice), new FormatConverter());    Assert.AreEqual(3500, o.Quantity);}
```

\


---

Original Source: https://www.mindstick.com/forum/1244/jsonconvert-string-to-integer-about-digit-grouping-symbol

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
