Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

APJSON

, 28 Aug 2013
This is an alternative for "fastJSON"
Apolyton_FastJson_Binaries__v0.92_.zip
Output
Debug
Apolyton.FastJson.dll
Release x64
Apolyton.FastJson.dll
Release x86
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Release
Apolyton.FastJson.dll
Silverlight
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Binaries__v0.93_.zip
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Binaries__v0.9_.zip
Apolyton.FastJson.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton_FastJson_Binaries__v1.0_.zip
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
apolyton_fastjson_sources__v0.92_.zip
Apolyton.FastJson
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Bin
Debug
Apolyton.Json.Silverlight.dll
Common
Data
Diagram.cd
obj
Debug
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Release x64
Apolyton.FastJson.dll
Release x86
Apolyton.FastJson.dll
Release
Apolyton.FastJson.dll
Properties
Registry
Serialization
Apolyton.FastJson.Tests
bin
Release
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Data
Helpers
ComplexTypes
ParameterRelated
Polymorphism
RegistryHelpers
StandardTypes
obj
Debug
Apolyton.FastJSON.Tests.dll
build.force
Release (x86, CUSTOM TYPES)
build.force
Release
Apolyton.FastJSON.Tests.dll
Properties
Registry
Serialization
Console Test
bin
Debug
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
DataObjects
obj
Debug
build.force
consoletest.exe
Release x64
consoletest.exe
Release x86
consoletest.exe
Release
build.force
consoletest.exe
Apolyton_FastJson_Sources__v0.93_.zip
Debug
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.dll
build.force
Apolyton.FastJSON.Tests.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Release
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
x86
Release (x86, CUSTOM TYPES)
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Release x64
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
consoletest.exe
consoletest.exe
consoletest.exe
consoletest.exe
x86
Debug
consoletest.exe
Release x64
consoletest.exe
Release x86
consoletest.exe
Release
consoletest.exe
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Apolyton.Json.Silverlight.dll
Release
Apolyton.Json.Silverlight.dll
Diagrams
Json.cd
JsonParameters.cd
TypeDescriptors.cd
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton.FastJson.dll
Apolyton.FastJson.dll
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Sources__v0.9_.zip
Apolyton.FastJson.csproj.user
Diagram.cd
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.dll
build.force
consoletest.vshost.exe
consoletest.exe
consoletest.exe
consoletest.exe
consoletest.exe
Apolyton_FastJson_Sources__v1.0_.zip
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
Json.cd
JsonParameters.cd
TypeDescriptors.cd
Apolyton.FastJson.csprojResolveAssemblyReference.cache
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
Apolyton.FastJson.Tests.csprojResolveAssemblyReference.cache
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
build.force
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.Tests.csprojResolveAssemblyReference.cache
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.pdb
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
consoletest.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Release (x86, CUSTOM TYPES)
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
consoletest.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Apolyton.FastJson.Registry;

namespace Apolyton.FastJson
{
    /// <summary>
    /// Represents the parameters for the json class. Changing instance values at runtime when a (de-)serialization is ongoing on that instance can lead to unexpected outcome. 
    /// Don't do it. 
    /// </summary>
    /// <remarks>
    /// http://www.codeproject.com/Articles/159450/fastJSON
    /// The version over there (2.0.9) could not be taken directly, as its serializer is taking all public properties, disregarding any attribute policy. This is
    /// not good for our case, as we want to return (portions of) data objects.
    /// <para/>
    /// Not thread safe.
    /// </remarks>
    public sealed class JsonParameters
    {
        private bool _useOptimizedDatasetSchema = true;
        private bool _useFastGuid = true;
        private bool _serializeNullValues = true;
        private bool _useUtcDateTime = true;

        private bool _usingGlobalTypes = true;
        private bool _ignoreCaseOnDeserialize = false;
        private bool _enableAnonymousTypes = false;
        private bool _useExtensions = true;

        private Encoding encoding = Encoding.UTF8;

        internal SerializationPolicy serializationPolicy = SerializationPolicy.PropertyOptOut;

        /// <summary>
        /// Creates an instance of the json parameters. For optimal performance, you should keep the instance in order to be reused. 
        /// </summary>
        public JsonParameters()
        {
            Registry = new JsonRegistry(this);
        }

        /// <summary>
        /// Returns the list of members which are concerded by (de-)serialization according to the current default parameters.
        /// </summary>
        public IEnumerable<JsonSerializationInfo> GetSerializationMembers(Type type)
        {
            return Registry.GetPropertiesAndFields(type, null).Values.Select(info => info.ToSerializationInfo());
        }

        /// <summary>
        /// Fixes values by disabling conflicting inputs.
        /// </summary>
        internal void FixValues()
        {
            if (UseExtensions == false) // disable conflicting params
            {
                UsingGlobalTypes = false;
            }
        }

        /// <summary>
        /// Gets the internal registry.
        /// </summary>
        internal readonly JsonRegistry Registry;

        /// <summary>
        /// Gets or sets the encoding of (input) json strings.
        /// </summary>
        public Encoding Encoding
        {
            get { return encoding; }
            set { encoding = value; }
        }

        /// <summary>
        /// Use the optimized fast Dataset Schema format (default = True)
        /// </summary>
        public bool UseOptimizedDatasetSchema
        {
            get { return _useOptimizedDatasetSchema; }
            set { _useOptimizedDatasetSchema = value; }
        }

        /// <summary>
        /// Use the fast GUID format. (default = True). The fast format is the base64 encoded byte array of the underlying guid. Otherwise a string representation of it. 
        /// (eg. 12345678-ABCD-ABCD-ABCD-1234567890AB).
        /// </summary>
        public bool UseFastGuid
        {
            get { return _useFastGuid; }
            set { _useFastGuid = value; }
        }

        /// <summary>
        /// Serialize null values to the output (default = True)
        /// </summary>
        public bool SerializeNullValues
        {
            get { return _serializeNullValues; }
            set { _serializeNullValues = value; }
        }

        /// <summary>
        /// Use the UTC date format (default = True)
        /// </summary>
        public bool UseUtcDateTime
        {
            get { return _useUtcDateTime; }
            set { _useUtcDateTime = value; }
        }

        /// <summary>
        /// Defines the serialization policy.
        /// </summary>
        public SerializationPolicy SerializationPolicy
        {
            get { return serializationPolicy; }
            set { serializationPolicy = value; }
        }

        /// <summary>
        /// Use the $types extension to optimise the output json (default = True). Can overridden (=False or true) during parsing under some conditions.
        /// </summary>
        public bool UsingGlobalTypes
        {
            get { return _usingGlobalTypes; }
            set { _usingGlobalTypes = value; }
        }

        /// <summary>
        /// ** work in progress
        /// </summary>
        public bool IgnoreCaseOnDeserialize
        {
            get { return _ignoreCaseOnDeserialize; }
            set { _ignoreCaseOnDeserialize = value; }
        }

        /// <summary>
        /// Anonymous types have read only properties 
        /// </summary>
        public bool EnableAnonymousTypes
        {
            get { return _enableAnonymousTypes; }
            set { _enableAnonymousTypes = value; }
        }

        /// <summary>
        /// Enable fastJSON extensions $types, $type, $map (default = True). Can overridden (=False) during parsing under some conditions.
        /// </summary>
        public bool UseExtensions
        {
            get { return _useExtensions; }
            set { _useExtensions = value; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Aron Kovacs

Germany Germany
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 28 Aug 2013
Article Copyright 2012 by Aron Kovacs
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid