I have a string that looks like this. It's not JSON and not XML.
{Foo={name=My Foo Value, active=true, some date=20170630}, Bar={name=My Bar Value}, Key With Space={name=Foo Bar, active=false}}
Here are the assumptions:
- Objects are enclosed by
{} - Keys can have a space in the name
- Keys are separated by a space and a comma (
,) - Values are assigned to keys by an equal sign
- Keys can have multiple values and values are enclosed by
{}, values inside the value are separated by a space and a comma (,). For example, this is a single key with three values:{My Foo Key={one=true, two=true, third value=false}}
My strategy is to deserialize to Dictionary<string, object at first, worry about recursion later. Any suggestions (existing library?) appreciated!
Here is what I have
var stringContentTrimmed = stringContent.Substring(1, stringContent.Length - 2);
var objects = stringContentTrimmed.Split(',')
.Select(x => x.Trim())
.Where(x => !String.IsNullOrWhiteSpace(x));
TLDR. The Split function is also splitting up my values, which isn't what I want.


Dictionary<string, object>. I'll use it later asmydict.TryGetValue("Foo", out fooValue).