While experimenting with your string, I discovered that it was incorrectly formatted. To address this issue, I have come up with a solution utilizing Regular Expressions
for extracting the data from the problematic string. You can view my implementation below along with a functional demonstration link here: https://dotnetfiddle.net/XLSde4
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
string str = "[{name:{buyerfirstname:Randy, buyermiddlename:null, buyerlastname:Johnson}, buyerfullname:Randy Johnson, businessname:null}]";
showMatch(str, @"(?<=[:,])(.*?)(?=\}[,\]])");
}
private static void showMatch(string text, string expr) {
MatchCollection mc = Regex.Matches(text, expr);
string[] matches=new string[10000];
foreach (Match m in mc) {
string tailored=m.Value.Trim().Replace("{","");
matches = Regex.Split(tailored, ",");
for(int i=0;i<matches.Length;i++)
{
Console.WriteLine(matches[i].ToString().Trim());
}
}
}
}
Result:
buyerfirstname:Randy
buyermiddlename:null
buyerlastname:Johnson
buyerfullname:Randy Johnson
businessname:null
This approach is intended to serve as a starting point or guide for you on this matter.