Bohn Bohn - 9 months ago 22
JSON Question

How to assign a JSON value to a string variable

Some value is saved in JSON format in DB and if I copy it from DB it looks like this:

[{"id":"FAC2SOUTHX","name":"South District MW ","description":"South District MW ","selected":true,"required":false,"sortOrder":10}]

Now I want to write a unit test that for its mock object I need to pass that value and the mock value is a string. But
giving error if I want to assign that value to a string variable. So I thought all I have to do is to prefix it with a
but didn't work either.
So how can I assign that value to a string variable.

ivo ivo

You have to comment all qoutes with a backslash so the string is recognized as a String e.g.

string s = "My string with \" qouted \" Values";