2

I've started using FastJSON and I'm having some problems for use it. I can't find any guide or documentation in internet, only a little extract in CodeProject.

For example: I've got this class:

[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; }
}

If I execute fastJSON.JSON.ToJSON(new Prueba()) i am getting this string:

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

But I was expecting this string:

"{"prueba1":5,"prueba2":6,"prueba3":"Hola"}"

As you can see, it is including some assembly information that I don't want in the string. I have tried playing with JSONParameters class, but I don't see any property for this situation.

So... Do you know how configure this?? Do you know any guide or documentation on internet to understand well how fastJSON works??

Thanks a lot, Regards

JorgeAM
  • 91
  • 2
  • 10

1 Answers1

9

Try setting UseSerializerExtension to false:

Something like:

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

EDIT

It appears the API has changed. You now need to pass an instance of JSONParameters

Like this

fastJSON.JSON.ToJSON(new Prueba(), new JSONParameters(){UseExtensions = false});
Alex
  • 37,502
  • 51
  • 204
  • 332
  • 2
    is it supposed to be `fastKSON`? I wanted to edit it but its not 6 characters :) – EpicKip May 17 '17 at 09:02
  • It appears i have fat fingers :) – Alex May 17 '17 at 09:06
  • Hi Alex, other error I get is trying to use Instance on fastJSON.JSON. Compiler say me that "fastJSON.JSON does not contain a definition for Instance". ¿Do you know why? Thanks!! – JorgeAM May 17 '17 at 09:34
  • @Neoff where does `fastJSON` come from? Can you show more of your code – Alex May 17 '17 at 09:35
  • @Alex I've created a new webforms application project (begining from zero) and i've installed fastJSON through Nuget Manager Window... On References, fastjson Library has been include by nuget. – JorgeAM May 17 '17 at 09:47
  • 1
    Exactly @Alex , with JSONParameters is solved. As there's no documentation about fastJSON I don't know what means each parameter. Thank you so much for all your help!!! – JorgeAM May 17 '17 at 10:30