Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Convert string to array

So I'm working with umbraco and using the tag datatype. I'm trying to take all tags added to a given node and putting them into an array of strings but when I grab the value it always seems to come out like this:

"[\"Tag1\",\"Tag2\"]"

How can I convert this string of an array back into a regular array? All I have gotten so far was a string of individual characters

like image 497
Michael F Avatar asked Jan 21 '26 15:01

Michael F


1 Answers

The array format you have provided as an example looks like part of the JSON object.

You could use JSON.net library to parse array token of the JSON object.

var array = JArray.Parse(tagString).Values<string>();

A complete example is available here.

like image 95
Valera Kolupaev Avatar answered Jan 23 '26 05:01

Valera Kolupaev