PowerJSON is a fork of the smallest, fastest polymorphic JSON serializer--fastJSON.
Please read the article about fastJSON here.
Features of PowerJSON
Version 3 New Features
The following features and changes are added to version 3:
- Streaming serialization API.
- Type alias system for polymorphic deserialization.
- Changes of default settings for serialization.
- Deprecation of obsolete APIs.
Migration from Previous Versions or fastJSON to Version 3
- Change the assembly reference from fastJSON.dll to PowerJson.dll.
- Replace all
- Change JSON to Json in all API types and methods. Typically the
JSONclass and its
JSONParametersclass has been merged into
- Default values in the previous
JSONParametersclass has changed.
UseEscapedUnicodewill have the default value of false instead of true in previous versions.
- Some settings in the previous
JSONParametersclass has been renamed.
ShowReadOnlyFieldsshall be changed to
UsingGlobalTypesin the previous
JSONParametersare no longer used. No global types will be written to the serialized JSON string.
- The $type extension will show the alias (settable by calling the
OverrideTypeAlias< T> (String)method, or applying to the type with the
JsonTypeAliasAttribute) or FullName instead of the
AssemblyQualifiedNameof the type.
- All obsolete features in previous versions shall be removed or changed to corresponding API.
New Features before Version 3
The following features are added to the original fastJSON.
- Rename serialized members.
- Rename serialized Enum values.
- Deserializing non-public types.
- Serializing and deserializing non-public members.
- Polymorphic serialization without JSON extensions.
- Write out additional key-value pairs in the serialized JSON.
- Conditional serialization.
- Noninvasive control over serialization.
- Easiest implemetation of customized serialization and deserialization.
- A comprehensive documentation.
New Classes and Interfaces
The newly introduced classes and interfaces have brought more control onto each aspect in serialization.
- SerializationManager: Caches the reflection result and controls the serialization. Supports non-invasive control over serialization.
- IReflectionController: Controls every possible aspect in reflection for serialization.
- IJsonInterceptor: Intercepts JSON serialization and enables conditional serialization.
- IJsonConverter: Converts between various value types.
- JsonConverter<TOriginal,TSerialized>: A base class which implements
IJsonConverterand simplifies the data conversion.
This fork has empowered fastJSON to serialize and deserialize objects with additional attribute types. The attributes are listed below:
- JsonInterceptorAttribute: 1) controls the procedure of serialization. 2) allows conditional serialization. 3) allows writing out extra key-value pairs in the serialized object.
- JsonFieldAttribute: 1) controls the name of the serialized field or property. 2) allows serializing interface or abstract types with the Type and Name conbination in the attribute.
- JsonIncludeAttribute: 1) explicitly controls whether a field or property is serialized or not. 2) allows serializing readonly property even when the
ShowReadOnlyPropertiessetting is turned off.
- JsonConverterAttribute: allows transforming data before serialization.
- JsonEnumValueAttribute: controls the serialized literal name of an
- JsonSerializableAttribute: enables serializing and deserializing non-public types or members.
- JsonNonSerializedValueAttribute: prevents specified member value from serializing.
- JsonContainerAttribute: puts enumerable items into a field named by this attribute to fully serialize types implementing
- JsonTypeAliasAttribute: sets the alias of a type for polymorphic deserialization. +
+ new in version 3
Some .NET built-in attributes are also supported.
- DefaultValueAttribute: values equal to
DefaultValueAttribute.Valueare not serialized.
- ReadOnlyAttribute: values are not deserialized when
ReadOnlyAttribute.IsReadOnlyis set to true.
- DataMemberAttribute: Currently only the
Namesetting is supported, other settings such as
IsRequiredare not supported.
XML serialization attributes are optionally supported (listed below). By default, the support is disabled and can be accessed by creating a new
SerializationManager with a
JsonReflectionController which has that option turned on.
New Settings in JsonParameters
This fork introduced the following settings in
- NamingConvention: control the naming convention of serialized fields and properties. It has added support for camel-case, uppercase names.
- SerializeStaticMembers: control whether static fields or properties should be serialized. (2015-4-2)
- ShowReadOnlyFields: control whether readonly fields should be serialized. (2015-4-7)
- SerializeEmptyCollections: control whether zero length collections, arrays, lists, dictionaries, etc. are serialized. (2015-4-25)
This fork also fixed some issues in the original fastJSON project:
- The serialized
Enumvalue could be incorrect when the underlying type is
Nullvalues were ignored in deserialization (when the constructor initialize the value of the member, in deserialization, the
nullvalue should not be ignored and set the member to
- Multi-value items in
NameValueCollectionwere not serialized correctly.
TimeSpantype could cause application stack overflow. (2015-4-2)
staticfields were serialized regardless
ShowReadOnlyPropertieswas turned off. (2015-4-7)
ShowReadOnlyPropertieswas not in effect for the same type after change. (2015-4-7)
- Deserialization on
Dictionary<N, List<V>>type could fail. (2015-4-9)
- "Release" compiled edition did not support
- Multi-demensional arrays could not be deserialized. (2015-4-25)
List<T>list could not be deserialized. (2015-4-27)
HashSet<T>could not be serialized. (2015-5-13)
- Types implementing
IEnumerablecould not be fully serialized. (2015-8-25)
- Performance has been more thoroughly optimized. It is faster than the fastest :)
- The Beautify method of JSON has introduced a new parameter: decodeUnicode, which allows decode "\uXXXX" encoded Unicode characters into human readable ones.