Hi Sohani,
The concern with the listed order is ui can be slightly misleading.
For example actually "no" is a attribute of "address" element. But it is
listed after "city" field element. It will be misleading when "city" will
also have a attribute as shown below in the schema. There will be two
attribute elements listed in the diagram, first one will be a attribute of
"city" and the second one will be a attribute of "address".
A indentation for the attribute of "city" element will give separation for
the above concern, but if this "city" element is another complex object
type, then there will be a big gap between "address" element and it's
attribute "no" which can confuse the user.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://jsonschema.net",
"title" : "employees",
"type": "object",
"properties": {
"employee": {
"id": "http://jsonschema.net/employee",
"type": "array",
"items": {
"id": "http://jsonschema.net/employee/0",
"type": "object",
"properties": {
"firstname": {
"id": "http://jsonschema.net/employee/0/firstname",
"type": "string"
},
"lastname": {
"id": "http://jsonschema.net/employee/0/lastname",
"type": "string"
},
"address": {
"id": "http://jsonschema.net/employee/0/address",
"type": "object",
"properties": {
"city": {
"id": "http://jsonschema.net/employee/0/address/city",
"type": "string"
"properties": {
"@postalcode":{
"id": "http://jsonschema.net/employee/0/address/no
",
"type": "string"
}
}
},
* "@no": {*
"id": "http://jsonschema.net/employee/0/address/no",
"type": "string"
},
"road": {
"id": "http://jsonschema.net/employee/0/address/road",
"type": "string"
}
}
}
},
"required": [
"firstname",
"lastname",
"address"
]
},
"required": [
"0"
]
}
},
"required": [
"employee"
]
}
Thanks,
Nuwan
On Wed, Mar 16, 2016 at 11:00 AM, Nuwan Pallewela <[email protected]> wrote:
> Hi Sohani,
>
> +1 for using "@" for attribute.
>
> Suggestion for listing attributes. Attributes under a element should
> listed before the other child field values.
> Eg: "no" field should list before city and road.
>
> Thanks,
> Nuwan
>
> On Wed, Mar 16, 2016 at 10:54 AM, Sohani Weerasinghe <[email protected]>
> wrote:
>
>> Hi,
>>
>> Please find the schema and the visual representation for representing the
>> attributes.
>>
>> {
>> "$schema": "http://json-schema.org/draft-04/schema#",
>> "id": "http://jsonschema.net",
>> "title" : "employees",
>> "type": "object",
>> "properties": {
>> "employee": {
>> "id": "http://jsonschema.net/employee",
>> "type": "array",
>> "items": {
>> "id": "http://jsonschema.net/employee/0",
>> "type": "object",
>> "properties": {
>> "firstname": {
>> "id": "http://jsonschema.net/employee/0/firstname",
>> "type": "string"
>> },
>> "lastname": {
>> "id": "http://jsonschema.net/employee/0/lastname",
>> "type": "string"
>> },
>> "address": {
>> "id": "http://jsonschema.net/employee/0/address",
>> "type": "object",
>> "properties": {
>> "city": {
>> "id": "http://jsonschema.net/employee/0/address/city",
>> "type": "string"
>> },
>> * "@no": {*
>> "id": "http://jsonschema.net/employee/0/address/no",
>> "type": "string"
>> },
>> "road": {
>> "id": "http://jsonschema.net/employee/0/address/road",
>> "type": "string"
>> }
>> }
>> }
>> },
>> "required": [
>> "firstname",
>> "lastname",
>> "address"
>> ]
>> },
>> "required": [
>> "0"
>> ]
>> }
>> },
>> "required": [
>> "employee"
>> ]
>> }
>>
>> Thanks,
>> Sohani
>>
>>
>>
>> Sohani Weerasinghe
>> Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile : +94 716439774
>> Blog :http://christinetechtips.blogspot.com/
>> Twitter : https://twitter.com/sohanichristine
>>
>> On Wed, Mar 16, 2016 at 10:35 AM, Sohani Weerasinghe <[email protected]>
>> wrote:
>>
>>> Thanks Nuwan. Shall we go with '@' then?
>>>
>>> Sohani Weerasinghe
>>> Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile : +94 716439774
>>> Blog :http://christinetechtips.blogspot.com/
>>> Twitter : https://twitter.com/sohanichristine
>>>
>>> On Wed, Mar 16, 2016 at 10:23 AM, Nuwan Pallewela <[email protected]>
>>> wrote:
>>>
>>>> Hi sohani,
>>>>
>>>> I think we do not need to include new type called "attr" to define it
>>>> as a attribute. We can name the field with a prefix like "@" or "attr_".
>>>>
>>>> Eg:
>>>> "@firstname": {
>>>> "id": "http://jsonschema.net/employee/0/firstname",
>>>> "type": "string"
>>>> },
>>>>
>>>> or
>>>>
>>>> "attr_firstname": {
>>>> "id": "http://jsonschema.net/employee/0/firstname",
>>>> "type": "string"
>>>> },
>>>>
>>>> Thanks,
>>>> Nuwan
>>>>
>>>> On Wed, Mar 16, 2016 at 10:15 AM, Sohani Weerasinghe <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Nuwan/ Viraj,
>>>>>
>>>>> Can you please mention how are we going to handle $subject?
>>>>>
>>>>> Can we have a new field as attr as below to handle the attributes?
>>>>>
>>>>> "firstname": {
>>>>> "id": "http://jsonschema.net/employee/0/firstname",
>>>>> "type": "string",
>>>>> *"attr" : "xyz"*
>>>>> },
>>>>>
>>>>> Thanks,
>>>>> Sohani
>>>>>
>>>>> Sohani Weerasinghe
>>>>> Software Engineer
>>>>> WSO2, Inc: http://wso2.com
>>>>>
>>>>> Mobile : +94 716439774
>>>>> Blog :http://christinetechtips.blogspot.com/
>>>>> Twitter : https://twitter.com/sohanichristine
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> ----------------------------------------------------------
>>>>
>>>> *Nuwan Chamara Pallewela*
>>>>
>>>>
>>>> *Software Engineer*
>>>>
>>>> *WSO2, Inc. *http://wso2.com
>>>> *lean . enterprise . middleware*
>>>>
>>>> Email *[email protected] <[email protected]>*
>>>> Mobile *+94719079739 <%2B94719079739>@*
>>>>
>>>>
>>>>
>>>
>>
>
>
> --
> ----------------------------------------------------------
>
> *Nuwan Chamara Pallewela*
>
>
> *Software Engineer*
>
> *WSO2, Inc. *http://wso2.com
> *lean . enterprise . middleware*
>
> Email *[email protected] <[email protected]>*
> Mobile *+94719079739 <%2B94719079739>@*
>
>
>
--
----------------------------------------------------------
*Nuwan Chamara Pallewela*
*Software Engineer*
*WSO2, Inc. *http://wso2.com
*lean . enterprise . middleware*
Email *[email protected] <[email protected]>*
Mobile *+94719079739 <%2B94719079739>@*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev