Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not clear to me if this example represents a potential infinite nesting of these JSON-esque groups, or just one level of nesting.</p> <p>If only one level of nesting is possible, a straightforward Regex will do:</p> <p>(Please note I did not write this with an IDE; the concept should be correct but syntax errors can't be guaranteed at the moment. Apologies)</p> <pre><code>string pattern = @"(?&lt;key&gt;)[A-Z]+)\s(?&lt;value&gt;({.+?}|[^{},]+))"; List&lt;string[]&gt; results = new List&lt;string[]&gt;(); //probably not best data structure MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.SingleLine | RegexOptions.IgnoreCase); foreach(Match match in matches) { if(match.Success) { results.Add(new string[] { match.Groups["key"].Value, match.Groups["value"].Value }); } } </code></pre> <p>If they can be nested many levels, you probably want to approach this recursively. That would necessitate splitting the value match into nested value and simple value:</p> <pre><code>string pattern = @"(?&lt;key&gt;)[A-Z]+)\s({(?&lt;nested&gt;.+?)}|(?&lt;simple&gt;[^{},]+))"; </code></pre> <p>And for each match where nested has a value, execute the same routine against that value:</p> <pre><code>void Deserialize(string input, List&lt;string[]&gt; values) { MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.SingleLine | RegexOptions.IgnoreCase); foreach(Match match in matches) { if(match.Success) { if(match.Groups["nested"].Success &amp;&amp; !string.IsNullOrEmpty(match.Groups["nested"].Value)) { Deserialize(match.Groups["nested"].Value, values); } else { values.Add(new string[] { match.Groups["key"].Value, match.Groups["simple"].Value }); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload