-3
string sample = "{\"STACK_SIZE\":4,\"thes_stack\":[4,4]}";

how can I parse it using RE in C#?

Alan Moore
  • 71,299
  • 12
  • 93
  • 154
Sahib Khan
  • 497
  • 4
  • 17

1 Answers1

2

First of all this isn't a valid JSON, remove the backslashes. Second, using a library like JSON.NET you can parse your sample.

string sample = "{"STACK_SIZE":4, "thes_stack":[4,4]}";

var parsed = JsonConvert.DeserializeObject<dynamic>(sample);

that will parse it into a dynamic type, if you want something more strongly typed create your own class:

class StackInfo
{
    public int STACK_SIZE {get; set;}
    public int[] thes_stack {get; set;}
}

then you can deserialize into it:

string sample = "{"STACK_SIZE":4, "thes_stack":[4,4]}";

var parsed = JsonConvert.DeserializeObject<StackInfo>(sample);

But since you didn't put exactly what you need or exactly what your problem is with the suggestions in the comments no one can really help you.

Tamim Al Manaseer
  • 3,374
  • 3
  • 22
  • 33