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
  • 38,279
  • 56
  • 171
  • 280
Rafee
  • 3,845
  • 8
  • 57
  • 86

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,779
  • 2
  • 25
  • 40