is "name" attribute can be unknown ?

Oxygen general issues.
avico
Posts: 1
Joined: Tue Sep 08, 2020 3:23 pm

is "name" attribute can be unknown ?

Post by avico »

Hi All,

first post here so hopefully i post it in right place,
Im new to Oxygen and facing some issue manipulating Json scheme ,
Json scheme for some tool im using for processing Json ,
The problem:

I need to change the Json scheme to support multiple object where the KEY name can be change ,
in example:
```
{
"parameter": {
"AppliedCampaignID": {
"name": "AppliedCampaignID",
"valueTo": "a",
"unitOfMeasure": null,
"value": "111",
"valueFrom": "c"
}, "B": {
"name": "B",
"valueTo": "B|",
"unitOfMeasure": null,
"value": "111",
"valueFrom": "A"
}
}
}
```

As u see parameter is object which can single/multiple objects,
where the object name is unknown ,

In Oxygen I try manipulate the attributes but couldn't manage to get element "B" to support name as unknown .
parameter set to "[CT - anonymous]" and relate to B element with sequence (as B can be multiple ).
image.png
image.png (30.54 KiB) Viewed 965 times

full json scheme:

```
<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:json="http://www.informatica.com/JSON/V1/single_obj_DP" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.informatica.com/JSON/V1/single_obj_DP">
<xs:annotation json:name="json_original_schema">
<xs:documentation>{
"type" : "object",
"required" : false,
"properties" : {
"parameter" : {
"type" : "object",
"required" : false,
"properties" : {
"AppliedCampaignID" : {
"type" : "object",
"required" : false,
"properties" : {
"name" : {
"type" : "string",
"required" : false,
"DT_INTERNAL_JSON_PRECISION_VALUE" : 21
},
"valueTo" : {
"type" : "null",
"required" : false
},
"unitOfMeasure" : {
"type" : "null",
"required" : false
},
"value" : {
"type" : "string",
"required" : false,
"DT_INTERNAL_JSON_PRECISION_VALUE" : 4
},
"valueFrom" : {
"type" : "null",
"required" : false
}
}
}
}
}
}
}</xs:documentation>
</xs:annotation>
<xs:element name="single_obj_DP">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" name="parameter">
<xs:complexType>
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element maxOccurs="1" minOccurs="0" name="B">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" name="name" type="xs:string">
<xs:annotation json:precision_value="21"/>
</xs:element>
<xs:element minOccurs="0" name="valueTo" type="json:JSON_NULL"/>
<xs:element minOccurs="0" name="unitOfMeasure" type="json:JSON_NULL"/>
<xs:element minOccurs="0" name="value" type="xs:string">
<xs:annotation json:precision_value="4"/>
</xs:element>
<xs:element minOccurs="0" name="valueFrom" type="json:JSON_NULL"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:simpleType name="JSON_DATA">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="JSON_NULL">
<xs:restriction base="xs:string">
<xs:maxLength value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>


````
florin_nica
Posts: 32
Joined: Wed Sep 09, 2020 3:17 pm

Re: is "name" attribute can be unknown ?

Post by florin_nica »

Hi,

Yes, you posted it in the right place, but it is a bit unclear. It seems that you are trying to manipulate an XML Schema, that contains a JSON Schema as an annotation. The Design page is not available yet for JSON Schema, but you can use the Oxygen tools to convert your XML Schema to a JSON Schema and validate your JSON example.
Regarding the problem with key name, you can use "patternProperties" to specify that a name is "unknown". Maybe your JSON Schema should look like this:

Code: Select all

{
    "$schema": "https://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": ["parameter"],
    "properties": {
        "parameter": {
            "type": "object",
            "patternProperties": {
                "^*$": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string",
                            "DT_INTERNAL_JSON_PRECISION_VALUE": 21
                        },
                        "valueTo": {
                            "type": "string"
                        },
                        "unitOfMeasure": {
                            "type": "null"
                        },
                        "value": {
                            "type": "integer",
                            "DT_INTERNAL_JSON_PRECISION_VALUE": 4
                        },
                        "valueFrom": {
                            "type": "string"
                        }
                    }
                }
            },
            "additionalProperties": false
        }
    }
}
Hope this helps.

Florin
Post Reply