Javascript 在字符串中添加引号,使其成为C中的JSON#

Javascript 在字符串中添加引号,使其成为C中的JSON#,javascript,c#,typescript,.net-core,json.net,Javascript,C#,Typescript,.net Core,Json.net,我正在使用一个使用JSON格式的服务 但从这里我得到的JSON并没有在键和值周围包含双引号 这是我拥有的数据的例子 [{name:{buyerfirstname:Randy, buyermiddlename:null, buyerlastname:Johnson}, buyerfullname:Randy Johnson, businessname:null}] 如何在C中将其转换为JSON# 注意:null不应包含双引号,因此,我在处理您的字符串,并根据您的字符串格式不正确的注释,设计了一种

我正在使用一个使用JSON格式的服务

但从这里我得到的JSON并没有在键和值周围包含双引号

这是我拥有的数据的例子

[{name:{buyerfirstname:Randy, buyermiddlename:null, buyerlastname:Johnson}, buyerfullname:Randy Johnson, businessname:null}]
如何在C中将其转换为JSON#


注意:null不应包含双引号

,因此,我在处理您的字符串,并根据您的字符串格式不正确的注释,设计了一种使用
正则表达式
解析相关字符串中数据的方法。请在下面找到我尝试的代码和一个工作示例:


我希望这能帮你解决问题,或者至少能给你一个开始的方向。

如果属性名和字符串值没有被引用,那就不是JSON了。所以
buyerfullname
就被放在那里了,空白和所有?这是什么样的服务…?您(或您的web服务)将Javascript Literal对象与JSON@Pac0这甚至不是说你应该修复或取消这项服务,这取决于哪一项是可能的。谢谢你的努力。需要一些调整,但至少有一些help@mohammedzaid很高兴听到这个消息,先生。
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());
            }   
         }
      }
}
buyerfirstname:Randy
buyermiddlename:null
buyerlastname:Johnson
buyerfullname:Randy Johnson
businessname:null