0

Hi Im having trouble getting the Javascript serialiser to convert this Json string to alist of strings

{'Roles':['Role1','Role2','Role3','Role4']}";

(new JavaScriptSerializer()).Deserialize< List<String> >( strInput )

it returns an empty list

2 Answers 2

2
['Role1','Role2','Role3','Role4']

would be

 List<string>

What you have with

{'Roles':['Role1','Role2','Role3','Role4']}

is

 Dictionary<string, List<string>>
Sign up to request clarification or add additional context in comments.

Comments

1

You are leaving out the top-level node which contains the array. That JSON could actually represent an object Foo with one property Roles that could be a List of string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.