0

I have a below json string and i am trying to get the "Company" array into C# Array

but i could not.. i have gone through other question over web, I found few serialization and Newtonsoft JSON Convert. but i don't have newtonsoft assembly on server as i am using a shared.. is there any way i get the

How can i get values from Json Array in C# Array and Json key value in C# string and integer array type?

I am using .net 4.0

{"Company": ["BMW", "Mercedes"], "Year":["2011","2014"], "request_id":"4"}
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Rafee
  • 3,975
  • 8
  • 58
  • 88

1 Answers1

1

Yes, you can do it with REGEX

using System.Text.RegularExpressions;

var jsonString = "{\"Company\": [\"BMW\", \"Mercedes\"], \"Year\":[\"2011\",\"2014\"], \"request_id\":\"4\"}";
var regexPattern = @"""Company"":\s\[(""\w+"".\s?)+";
Regex.Match(jsonString, regexPattern)
//Result => ["Company": ["BMW", "Mercedes"]]

Regex.Match(jsonString, regexPattern).Groups[1]
//["BMW", "Mercedes"]]
Alberto Monteiro
  • 5,989
  • 2
  • 28
  • 40