Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Personal fork of fastJSON
C#
Branch: master
Failed to load latest commit information.
.nuget Organized solution
Tests.Console Rename project folders to match project names
Tests.Unit Made PascalCase the only default variant to use to increase performan…
fastJSON-SL
fastJSON-WP7
fastJSON
.gitattributes Original project checkin (base)
.gitignore Organized solution
LICENSE.txt
Readme.md
SharedAssemblyInfo.cs
fastJSON.sln Added CPOL license, added readme with changes outlined
history.txt

Readme.md

fastJSON Fork

This is a fork of the fastJSON project from Mehdi Gholam. It is not really meant to be kept in-sync necessarily, it just has some features that I need.

fastJSON uses the CPOL 1.2 license.

Name variance based on RestSharp (Apache 2.0).

Changes from Official

  • Windows Phone support out-of-the-box
  • Name variant support when deserializing. This uses the same logic from RestSharp.
    • last_name => LastName, lastName, etc.
  • Root element support. This allows you to specify the first element in the result JSON to use as a starting point for the parser, preventing you from having to create container classes.
    • fastJSON.JSON.Instance.ToObject<T>(json, rootElement: "container")
  • Auto-generates a multi-targeted Nuget package

Name Variance

// Defaults
fastJSON.JSONParameters.MatchNameVariantsOnDeserialize = false;
fastJSON.JSONParameters.EnabledNameVariantFlags = NameVariants.PascalCase;

If your service/API returns a JSON response like this:

    {
        "first_name": "Kamran",
        "last_name": "Ayub"
    }

And you have a POCO class:

    public class Person {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

fastJSON will not match the property names up as it expects an exact or lowercase match.

However, with the name variance feature, it will properly discover and match up the properties. This adds some extra overhead, so you can enable it like this:

fastJSON.JSONParameters.MatchNameVariantsOnDeserialize = true;

Since each variant has a perf impact, you can enable/disable them when you know what response you expect back:

fastJSON.JSONParameters.EnabledNameVariantFlags = NameVariants.PascalCase;

With all matches enabled, it can add 2-3x the amount of time to deserialize an object.

License

See LICENSE.txt

Something went wrong with that request. Please try again.