ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / DatumTransformation Class / CreateFromJson Method
The JSON string.
Example Version

CreateFromJson Method (DatumTransformation)
Creates a CompositeGeographicTransformation or CompositeHVDatumTransformation from the input JSON string.
Syntax
public static DatumTransformation CreateFromJson( 
   string jsonString
)

Parameters

jsonString
The JSON string.

Return Value

Exceptions
ExceptionDescription
The JSON string is null or empty.
Example
Create Composite Geographic Transformation
// Create singleton from wkid
CompositeGeographicTransformation cgt = 
    ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(108272);
int count = cgt.Count;    // count = 1

IList<GeographicTransformation> gts = cgt.Transformations 
                                as IList<GeographicTransformation>;
gts.Add(ArcGIS.Core.Geometry.GeographicTransformation.Create(1437, false));
count = cgt.Count;        // count = 2

// create from an enumeration
CompositeGeographicTransformation another_cgt = 
              ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(gts);
GeographicTransformation gt0 = another_cgt[0];
GeographicTransformation gt1 = another_cgt[1];

// get the inverse
CompositeGeographicTransformation inversed_cgt = another_cgt.GetInverse() as CompositeGeographicTransformation;
// inversed_cgt[0] is same as gt1
// inversed_cgt[1] is same as gt0

var wkt = gt0.Wkt;
// create from string 
CompositeGeographicTransformation third_cgt = 
   ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(wkt, gt0.IsForward);
count = third_cgt.Count;        // count = 1

// create from josn
string json = cgt.ToJson();
CompositeGeographicTransformation joson_cgt = 
  DatumTransformation.CreateFromJson(json) as CompositeGeographicTransformation;
Create Composite HV Datum Transformation
HVDatumTransformation hv1 = HVDatumTransformation.Create(108034);
HVDatumTransformation hv2 = HVDatumTransformation.Create(108033, false);
List<HVDatumTransformation> hvs = new List<HVDatumTransformation>() { hv1, hv2 };

// create from enumeration
CompositeHVDatumTransformation compositehv = 
                CompositeHVDatumTransformation.Create(hvs);
int count = compositehv.Count;      // count = 2

List<HVDatumTransformation> transforms = 
               compositehv.Transformations as List<HVDatumTransformation>;
HVDatumTransformation tranform = transforms[0];
// transform.Wkid = 108034

// get inverse
CompositeHVDatumTransformation inverse_compositehv = 
       compositehv.GetInverse() as CompositeHVDatumTransformation;

// create from xml
string xml = compositehv.ToXml();
//At 2.x - CompositeHVDatumTransformation xml_compositehv =
//      CompositeHVDatumTransformation.CreateFromXML(xml);

var xml_compositehv = CompositeHVDatumTransformation.CreateFromXml(xml);

// create from json
string json = compositehv.ToJson();
CompositeHVDatumTransformation json_compositehv = 
    DatumTransformation.CreateFromJson(json) as CompositeHVDatumTransformation;
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also