Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FastJSON-如何使用?_C#_.net_Json_Fastjson - Fatal编程技术网

C# FastJSON-如何使用?

C# FastJSON-如何使用?,c#,.net,json,fastjson,C#,.net,Json,Fastjson,我已经开始使用FastJSON,但在使用它时遇到了一些问题。我在互联网上找不到任何指南或文档,只有CodeProject中的一点摘录 例如:我有一门课: [Serializable] public class Prueba { public Prueba() { prueba1 = 5; prueba2 = 6; prueba3 = "Hola"; } public int prueba1 { get; set;

我已经开始使用FastJSON,但在使用它时遇到了一些问题。我在互联网上找不到任何指南或文档,只有CodeProject中的一点摘录

例如:我有一门课:

[Serializable]
public class Prueba
{
    public Prueba()
    {
        prueba1 = 5;
        prueba2 = 6;
        prueba3 = "Hola";
    }

    public int prueba1 { get; set; }
    public int prueba2 { get; set; }
    public string prueba3 { get; set; }
}
如果我执行
fastJSON.JSON.ToJSON(new Prueba())
我将得到以下字符串:

{“$types”:{“WebApplication3.Prueba,WebApplication3,Version=1.0.0,Culture=neutral,PublicKeyToken=null”:“1”},$type:“1”,“prueba1”:5,“prueba2”:6,“prueba3”:“Hola”}

但我期待着这个字符串:

{“普鲁巴1”:5,“普鲁巴2”:6,“普鲁巴3”:“你好”}

如您所见,它包含了一些我不希望出现在字符串中的程序集信息。我尝试过使用JSONParameters类,但没有看到这种情况下的任何属性

所以。。。你知道如何配置这个吗??你知道互联网上有什么指南或文档可以很好地理解fastJSON的工作原理吗

非常感谢,
考虑到

请尝试将
UseSerializerExtension
设置为false:

比如:

fastJSON.JSON.Instance.UseSerializerExtension = false;
fastJSON.JSON.ToJSON(new Prueba());
编辑

看来API已经改变了。现在需要传递
JSONParameters

像这样

fastJSON.JSON.ToJSON(new Prueba(), new JSONParameters(){UseExtensions = false});

如果初始化Prueba,然后才将实例传递给该方法,会发生什么情况?@Orangesandlemons
new Prueba()
初始化(创建)一个新实例?@FelixD。关于Prueba,是的。@Orangesandlemons发生了完全相同的事情:(它应该是
fastKSON
?我想编辑它,但不是6个字符:)看起来我有胖手指:)嗨,Alex,我遇到的另一个错误是试图使用fastJSON.JSON上的实例。编译器告诉我“fastJSON.JSON不包含实例的定义”。你知道为什么吗?谢谢@Neoff
fastJSON
来自哪里?你能展示更多你的代码吗?@Alex,JSONParameters已经解决了。由于没有关于fastJSON的文档,我不知道每个参数的含义。非常感谢你的帮助!!!