Class JsonTransformer


  • public class JsonTransformer
    extends Object
    • Constructor Detail

      • JsonTransformer

        public JsonTransformer()
    • Method Detail

      • makeStructureTypes

        public static String makeStructureTypes​(manifold.api.host.IManifoldHost host,
                                                String nameForStructure,
                                                manifold.rt.api.Bindings bindings,
                                                AbstractJsonTypeManifold tm,
                                                boolean mutable)
        Makes a tree of structure types reflecting the Bindings.

        If the bindings represent a Json Schema format (v.4), the types are transformed according to that schema. Otherwise, the bindings are assumed to be a sample Json document whereby types are derived directly from the sample. Note when multiple samples exist for the same type eg., array elements, the samples are merged and reconciled.

        A structure type contains a property member for each name/value pair in the Bindings. A property has the same name as the key and follows these rules:

        • If the type of the value is a "simple" type, such as a String or Integer, the type of the property matches the simple type exactly
        • Otherwise, if the value is a Bindings type, the property type is that of a child structure with the same name as the property and recursively follows these rules
        • Otherwise, if the value is a List, the property is a List parameterized with the component type, and the component type recursively follows these rules
      • transformJsonObject

        public static IJsonType transformJsonObject​(manifold.api.host.IManifoldHost host,
                                                    String name,
                                                    manifold.api.fs.IFile source,
                                                    JsonSchemaType parent,
                                                    Object jsonObj)