Namespace: OpenEdge.Core.Json
Type: Class JsonSerializer
Parent Classes:
Progress.Lang.Object

Inherits: Progress.Lang.Object


/* *************************************************************************************************************************
Copyright (c) 2019-2021 by Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
File:OpenEdge.Core.Json.JsonSerializer
Description:Serilaizes to and from JSON
Author(s):pjudge
Created:2019-11-21



Method Summary
  Options Name Purpose
  Progress.Lang.Object Deserialize (JsonArray) /* Deserializes an array of object from a JSON array.. Integer values are references to objects in the array - if there are duplicates then only one has to be (de)serialised. References must be 'backwards' (ie to an already-deserialised object). @param JsonArray An array represented as JSON @return Progress.Lang.Object[] A deserialised object array */
  Progress.Lang.Object Deserialize (JsonObject) /* Deserializes this object from JSON. @param JsonConstruct This object represented as JSON @return Progress.Lang.Object A deserialised object */
  OpenEdge.Core.Json.IJsonSerializer NewSerializableObject (Class) /* Instantiates a new instance of an IJsonSerializable object. This method attempts to find a service using the CCS Service Manager, using IJsonSerializable as the service name, and the type name as an alias. If none is found or returned, then the method requires that the type implement IJsonSerializable, be NEW'able (not abstract and not an interface) and also have a public default constructor. @param Progress.Lang.Class The type to instantiate @return IJsonSerializer An object of that type */
  Progress.Json.ObjectModel.JsonObject Serialize (Object) /* Serialises an object to JSON. This method first tries to serialize using OpenEdge.Core.Json.IJsonSerializer and then Progress.IO.JsonSerializer. If the class implements neither then an invalid object is returned. If the class implements IJsonSerializer then the JSON returned has the format { "serializer": <STRING> // OOABL type name of the IJsonSerializer interface "object": <STRING> // OOABL type name of the object being serialised "data": <NULL|OBJECT|ARRAY> // the serialized object data } If the class uses the built-in serilisation, then the JSON format is { "prods:version": <VERISON>, "prods:objId", <internal ID of this object)> "<STRING>" : { // the string is the OOABL type name of the class being serialised // serialisation data, per doc } } @param Progress.Lang.Object The object to serialize @return JsonObject The JSON data. May be invalid/unknown */
  Progress.Json.ObjectModel.JsonArray Serialize (Object[]) /* Serialises an array of objects to JSON. This method first tries to serialize using OpenEdge.Core.Json.IJsonSerializer and then Progress.IO.JsonSerializer. If the class implements neither then an invalid object is returned. If there are duplicate objects in the array, then the index of the duplicate object is written @param Progress.Lang.Object[] The objects to serialize @return JsonArray The JSON data. May be invalid/unknown */
  Progress.Lang.Object ToAblObject (JsonObject, Class) /* Attempts to create an object of a specific type from serialised JSON data. Delegates to ToAblObject(JsonObject, P.L.Class, P.L.Class) ; see that method for details of behaviour. @param JsonObject The serialised data @param Progress.Lang.Class (mandatory) The type of the object. This is used as the defined and implementation type @return Progress.Lang.Object An object instance, based on the defined type. May be null if the criteria for types isn't met */
  Progress.Lang.Object ToAblObject (JsonObject, Class, Class) /* Attempts to create an object of a specific type from serialised JSON data. 1) Try to deserialize the JSON using this class' Deserialize() method. If not valid, 2) Try to get an instance of the defined type (from the Service Manager). If not valid, 3) Try to get an instance of the implementation type (from the Service Manager). 4) If valid, and meets the 'instantiable' criteria, deserialise using the JSON data 5) If not, return null @param JsonObject (optional) The serialised data @param Progress.Lang.Class (mandatory) The "defined type" of the object. @param Progress.Lang.Class (mandatory) The "implementation type" of the object. Must be instantiable - not an interface, nor abstract, default public constructor - and must implement IJsonSerializer @return Progress.Lang.Object An object instance of the "defined type". May be null if the criteria for types isn't met */

Constructor Summary
  Options Name Purpose
  JsonSerializer () /* Default constructor. This is private so that this class cannot be instantiated - it's intended to be used with static members only */

Property Summary
  Options Name Purpose
  CHARACTER PROP_DATA
  CHARACTER PROP_OBJECT
  CHARACTER PROP_PRODS-VERSION
  CHARACTER PROP_SERIALIZER


Method Detail
Top

Progress.Lang.Object Deserialize (JsonArray)

/* Deserializes an array of object from a JSON array..
Integer values are references to objects in the array - if there are duplicates
then only one has to be (de)serialised. References must be 'backwards' (ie to an
already-deserialised object).
Parameters:
pJson Progress.Json.ObjectModel.JsonArray
 
Returns Progress.Lang.Object
  Progress.Lang.Object[] A deserialised object array
Top

Progress.Lang.Object Deserialize (JsonObject)

/* Deserializes this object from JSON.
Parameters:
pJson Progress.Json.ObjectModel.JsonObject
 
Returns Progress.Lang.Object
  Progress.Lang.Object A deserialised object
Top

OpenEdge.Core.Json.IJsonSerializer NewSerializableObject (Class)

/* Instantiates a new instance of an IJsonSerializable object.
This method attempts to find a service using the CCS Service Manager, using IJsonSerializable as
the service name, and the type name as an alias.
If none is found or returned, then the method requires that the type implement IJsonSerializable, be NEW'able
(not abstract and not an interface) and also have a public default constructor.
Parameters:
pType Progress.Lang.Class
 
Returns OpenEdge.Core.Json.IJsonSerializer
  IJsonSerializer An object of that type
Top

Progress.Json.ObjectModel.JsonObject Serialize (Object)

/* Serialises an object to JSON.
This method first tries to serialize using OpenEdge.Core.Json.IJsonSerializer and
then Progress.IO.JsonSerializer. If the class implements neither then an invalid object
is returned.
If the class implements IJsonSerializer then the JSON returned has the format
{
"serializer": <STRING> // OOABL type name of the IJsonSerializer interface
"object": <STRING> // OOABL type name of the object being serialised
"data": <NULL|OBJECT|ARRAY> // the serialized object data
}
If the class uses the built-in serilisation, then the JSON format is
{
"prods:version": version": <VERISON>,
"prods:objId", objId", <internal ID of this object)>
"<STRING>" : { // the string is the OOABL type name of the class being serialised
// serialisation data, per doc
}
}
Parameters:
pSerialize Progress.Lang.Object
 
Returns Progress.Json.ObjectModel.JsonObject
  JsonObject The JSON data. May be invalid/unknown
Top

Progress.Json.ObjectModel.JsonArray Serialize (Object[])

/* Serialises an array of objects to JSON.
This method first tries to serialize using OpenEdge.Core.Json.IJsonSerializer and
then Progress.IO.JsonSerializer. If the class implements neither then an invalid object
is returned.
If there are duplicate objects in the array, then the index of the duplicate object is written
Parameters:
pSerialize Progress.Lang.Object
 
Returns Progress.Json.ObjectModel.JsonArray
  JsonArray The JSON data. May be invalid/unknown
Top

Progress.Lang.Object ToAblObject (JsonObject, Class)

/* Attempts to create an object of a specific type from serialised JSON data.
Delegates to ToAblObject(JsonObject, P.L.Class, P.L.Class) ; see that method for details of behaviour.
Parameters:
pJsonData Progress.Json.ObjectModel.JsonObject
 
pType Progress.Lang.Class
 
Returns Progress.Lang.Object
  Progress.Lang.Object An object instance, based on the defined type. May be null if the criteria for types isn't met
Top

Progress.Lang.Object ToAblObject (JsonObject, Class, Class)

/* Attempts to create an object of a specific type from serialised JSON data.
1) Try to deserialize the JSON using this class' Deserialize() method. If not valid,
2) Try to get an instance of the defined type (from the Service Manager). If not valid,
3) Try to get an instance of the implementation type (from the Service Manager).
4) If valid, and meets the 'instantiable' criteria, deserialise using the JSON data
5) If not, return null
nor abstract, default public constructor - and must implement IJsonSerializer
Parameters:
pJsonData Progress.Json.ObjectModel.JsonObject
 
pType Progress.Lang.Class
 
pImplementation Progress.Lang.Class
 
Returns Progress.Lang.Object
  Progress.Lang.Object An object instance of the "defined type". May be null if the criteria for types isn't met


Constructor Detail
Top

JsonSerializer ()

/* Default constructor.
This is private so that this class cannot be instantiated - it's intended to be used with static members only


Property Detail
Top

CHARACTER PROP_DATA

Returns CHARACTER
 
Top

CHARACTER PROP_OBJECT

Returns CHARACTER
 
Top

CHARACTER PROP_PRODS-VERSION

Returns CHARACTER
 
Top

CHARACTER PROP_SERIALIZER

Returns CHARACTER