user2320490
user2320490

Reputation: 31

Json formatted string to list

I have a string like this:

{"label":{"en":"Africa","de":"Afrika"},"description":{"en":"continent","de":"irdischer Kontinent"}}

Is possible convert to list like:

"label" - "en":"Africa","de":"Afrika"
"description" - "en":"continent","de":"irdischer Kontinent"

Thanks

Upvotes: 3

Views: 193

Answers (1)

p.s.w.g
p.s.w.g

Reputation: 149020

As others have suggested, it looks like you're trying to process a JSON document. I recommend Json.NET for this.

However, you can manipulate your string by itself if the transformation is very simple and you don't expect much variation in your input. One easy way would be to do something like this:

var result = input.Replace(":{", " - ")
                  .Replace("},", Environment.NewLine)
                  .Replace("{", string.Empty)
                  .Replace("}", string.Empty);

Upvotes: 3

Related Questions