-2

I use

var obj = response.Content.ReadAsStringAsync().Result; 

to get a result like

obj = {"productId":"12345"}.

How to get the value 12345 from the response result?

Developer
  • 8,390
  • 41
  • 129
  • 238
kfneu
  • 51
  • 1
  • 2

1 Answers1

-1

If you do not want to create an object & just need to quickly get the value, use Json.NET to parse your data into a JObject & then use .GetValue :

var productId = JObject.Parse(obj).GetValue("productId").Value<string>();

Or:

var productId = JObject.Parse(obj)["productId"].ToString();

Output:

"12345"

Ermiya Eskandary
  • 15,323
  • 3
  • 31
  • 44