Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Nuwan Pallewela
Problem is that we can not say that we are not guarantee the order of the
xml elements in data mapper. As there are some well known API's who
consider the order(some Salesforce API's), we have to support the order in
xml elements from our side. Otherwise there will be issues when user going
to use data mapper with such API's.

On Tue, Jun 21, 2016 at 10:43 AM, Harsha Thirimanna 
wrote:

> As in the spec , it can be choice, seq or mixed, right ? The ELEMENT Type
> Declaration can be used within an DTD to define the contents on an element
> within the XML document. Is that ok to make sequence for all the cases ?
>
>
> *Harsha Thirimanna*
> Associate Tech Lead; WSO2, Inc.; http://wso2.com
> * *
> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
> *twitter: **http://twitter.com/ *
> *harshathirimannlinked-in: **http:
> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
> *
>
> *Lean . Enterprise . Middleware*
>
>
> On Tue, Jun 21, 2016 at 10:17 AM, Nuwan Pallewela  wrote:
>
>> Hi Harsha,
>>
>> We can find this in section 3.2.1 Element Content in the W3C
>> recommendation[1].
>>
>> [1] https://www.w3.org/TR/REC-xml/
>>
>> Thanks,
>> Nuwan
>>
>> On Tue, Jun 21, 2016 at 10:02 AM, Harsha Thirimanna 
>> wrote:
>>
>>> Hi Nuwan,
>>>
>>> Thanks for pointing that, can you please point that
>>> specification location please ?
>>>
>>>
>>> *Harsha Thirimanna*
>>> Associate Tech Lead; WSO2, Inc.; http://wso2.com
>>> * *
>>> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
>>> *twitter: **http://twitter.com/ *
>>> *harshathirimannlinked-in: **http:
>>> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
>>> *
>>>
>>> *Lean . Enterprise . Middleware*
>>>
>>>
>>> On Tue, Jun 21, 2016 at 9:45 AM, Nuwan Pallewela 
>>> wrote:
>>>
 Hi Harsha,

 On Tue, Jun 21, 2016 at 9:27 AM, Harsha Thirimanna 
 wrote:

> Hi Sohani,
> Just wanted to know one thing and please make me correct if i am wrong
> here.
>
> Normally, XML elements don't have an order and any implementation
> should not depend on the order of the elements in XML file except if it
> has a XSD and saying it as a sequence.
>
 No. In the specification it is mentioned that XML consider order. And
 there are certain api's which consider the order of the elements. So we
 should to support it in xml.

> So why do we need to concern about the order here. Any special reason
> for that ?
>
>
> *Harsha Thirimanna*
> Associate Tech Lead; WSO2, Inc.; http://wso2.com
> * *
> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
> *twitter: **http://twitter.com/ *
> *harshathirimannlinked-in: **http:
> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
> *
>
> *Lean . Enterprise . Middleware*
>
>
> On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
> wrote:
>
>> Hi All,
>>
>> We are in a process of $subject and the main issue we faced in
>> generating the json schema was as follows.
>>
>> When generating the json schema we mainly convert the xml to json and
>> the xml to json conversion does not guarantee the order since json object
>> is an unordered set of name/value pairs [1].
>>
>> The main reason is the usage of HashMaps instead of LinkedHashMaps in
>> instantiating the JSONObjects and we could solve the issue by using the
>> LinkedHashMaps.
>>
>> This issue again occurs in serializing the schema while iterating
>> through the gmf tree, since we are generating the schema by creating the
>> JSONObjects and JSONArrays appropriately. We could solve this issue as 
>> well
>> by using the above solution and as a result, the generated tree and the
>> schema will maintain the order of the XML payload
>>
>> [1]
>> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>>
>> Thanks,
>> Sohani
>> Sohani Weerasinghe
>> Senior Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile  : +94 716439774
>> Blog :http://christinetechtips.blogspot.com/
>> Twitter  : https://twitter.com/sohanichristine
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev

Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Harsha Thirimanna
As in the spec , it can be choice, seq or mixed, right ? The ELEMENT Type
Declaration can be used within an DTD to define the contents on an element
within the XML document. Is that ok to make sequence for all the cases ?


*Harsha Thirimanna*
Associate Tech Lead; WSO2, Inc.; http://wso2.com
* *
*email: **hars...@wso2.com* * cell: +94 71 5186770 *
*twitter: **http://twitter.com/ *
*harshathirimannlinked-in: **http:
**//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
*

*Lean . Enterprise . Middleware*


On Tue, Jun 21, 2016 at 10:17 AM, Nuwan Pallewela  wrote:

> Hi Harsha,
>
> We can find this in section 3.2.1 Element Content in the W3C
> recommendation[1].
>
> [1] https://www.w3.org/TR/REC-xml/
>
> Thanks,
> Nuwan
>
> On Tue, Jun 21, 2016 at 10:02 AM, Harsha Thirimanna 
> wrote:
>
>> Hi Nuwan,
>>
>> Thanks for pointing that, can you please point that
>> specification location please ?
>>
>>
>> *Harsha Thirimanna*
>> Associate Tech Lead; WSO2, Inc.; http://wso2.com
>> * *
>> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
>> *twitter: **http://twitter.com/ *
>> *harshathirimannlinked-in: **http:
>> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
>> *
>>
>> *Lean . Enterprise . Middleware*
>>
>>
>> On Tue, Jun 21, 2016 at 9:45 AM, Nuwan Pallewela  wrote:
>>
>>> Hi Harsha,
>>>
>>> On Tue, Jun 21, 2016 at 9:27 AM, Harsha Thirimanna 
>>> wrote:
>>>
 Hi Sohani,
 Just wanted to know one thing and please make me correct if i am wrong
 here.

 Normally, XML elements don't have an order and any implementation
 should not depend on the order of the elements in XML file except if it
 has a XSD and saying it as a sequence.

>>> No. In the specification it is mentioned that XML consider order. And
>>> there are certain api's which consider the order of the elements. So we
>>> should to support it in xml.
>>>
 So why do we need to concern about the order here. Any special reason
 for that ?


 *Harsha Thirimanna*
 Associate Tech Lead; WSO2, Inc.; http://wso2.com
 * *
 *email: **hars...@wso2.com* * cell: +94 71 5186770 *
 *twitter: **http://twitter.com/ *
 *harshathirimannlinked-in: **http:
 **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
 *

 *Lean . Enterprise . Middleware*


 On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
 wrote:

> Hi All,
>
> We are in a process of $subject and the main issue we faced in
> generating the json schema was as follows.
>
> When generating the json schema we mainly convert the xml to json and
> the xml to json conversion does not guarantee the order since json object
> is an unordered set of name/value pairs [1].
>
> The main reason is the usage of HashMaps instead of LinkedHashMaps in
> instantiating the JSONObjects and we could solve the issue by using the
> LinkedHashMaps.
>
> This issue again occurs in serializing the schema while iterating
> through the gmf tree, since we are generating the schema by creating the
> JSONObjects and JSONArrays appropriately. We could solve this issue as 
> well
> by using the above solution and as a result, the generated tree and the
> schema will maintain the order of the XML payload
>
> [1]
> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>
> Thanks,
> Sohani
> Sohani Weerasinghe
> Senior Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev


>>> Thanks,
>>> Nuwan
>>>
>>> --
>>> --
>>>
>>> *Nuwan Chamara Pallewela*
>>>
>>>
>>> *Software Engineer*
>>>
>>> *WSO2, Inc. *http://wso2.com
>>> *lean . enterprise . middleware*
>>>
>>> Email   *nuw...@wso2.com *
>>> Mobile  *+94719079739 <%2B94719079739>@*
>>>
>>>
>>>
>>
>
>
> --
> 

Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Nuwan Pallewela
Hi Harsha,

We can find this in section 3.2.1 Element Content in the W3C
recommendation[1].

[1] https://www.w3.org/TR/REC-xml/

Thanks,
Nuwan

On Tue, Jun 21, 2016 at 10:02 AM, Harsha Thirimanna 
wrote:

> Hi Nuwan,
>
> Thanks for pointing that, can you please point that specification location
> please ?
>
>
> *Harsha Thirimanna*
> Associate Tech Lead; WSO2, Inc.; http://wso2.com
> * *
> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
> *twitter: **http://twitter.com/ *
> *harshathirimannlinked-in: **http:
> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
> *
>
> *Lean . Enterprise . Middleware*
>
>
> On Tue, Jun 21, 2016 at 9:45 AM, Nuwan Pallewela  wrote:
>
>> Hi Harsha,
>>
>> On Tue, Jun 21, 2016 at 9:27 AM, Harsha Thirimanna 
>> wrote:
>>
>>> Hi Sohani,
>>> Just wanted to know one thing and please make me correct if i am wrong
>>> here.
>>>
>>> Normally, XML elements don't have an order and any implementation should
>>> not depend on the order of the elements in XML file except if it has a XSD
>>> and saying it as a sequence.
>>>
>> No. In the specification it is mentioned that XML consider order. And
>> there are certain api's which consider the order of the elements. So we
>> should to support it in xml.
>>
>>> So why do we need to concern about the order here. Any special reason
>>> for that ?
>>>
>>>
>>> *Harsha Thirimanna*
>>> Associate Tech Lead; WSO2, Inc.; http://wso2.com
>>> * *
>>> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
>>> *twitter: **http://twitter.com/ *
>>> *harshathirimannlinked-in: **http:
>>> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
>>> *
>>>
>>> *Lean . Enterprise . Middleware*
>>>
>>>
>>> On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
>>> wrote:
>>>
 Hi All,

 We are in a process of $subject and the main issue we faced in
 generating the json schema was as follows.

 When generating the json schema we mainly convert the xml to json and
 the xml to json conversion does not guarantee the order since json object
 is an unordered set of name/value pairs [1].

 The main reason is the usage of HashMaps instead of LinkedHashMaps in
 instantiating the JSONObjects and we could solve the issue by using the
 LinkedHashMaps.

 This issue again occurs in serializing the schema while iterating
 through the gmf tree, since we are generating the schema by creating the
 JSONObjects and JSONArrays appropriately. We could solve this issue as well
 by using the above solution and as a result, the generated tree and the
 schema will maintain the order of the XML payload

 [1]
 http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion

 Thanks,
 Sohani
 Sohani Weerasinghe
 Senior Software Engineer
 WSO2, Inc: http://wso2.com

 Mobile  : +94 716439774
 Blog :http://christinetechtips.blogspot.com/
 Twitter  : https://twitter.com/sohanichristine

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev


>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>> Thanks,
>> Nuwan
>>
>> --
>> --
>>
>> *Nuwan Chamara Pallewela*
>>
>>
>> *Software Engineer*
>>
>> *WSO2, Inc. *http://wso2.com
>> *lean . enterprise . middleware*
>>
>> Email   *nuw...@wso2.com *
>> Mobile  *+94719079739 <%2B94719079739>@*
>>
>>
>>
>


-- 
--

*Nuwan Chamara Pallewela*


*Software Engineer*

*WSO2, Inc. *http://wso2.com
*lean . enterprise . middleware*

Email   *nuw...@wso2.com *
Mobile  *+94719079739@*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Harsha Thirimanna
Hi Nuwan,

Thanks for pointing that, can you please point that specification location
please ?


*Harsha Thirimanna*
Associate Tech Lead; WSO2, Inc.; http://wso2.com
* *
*email: **hars...@wso2.com* * cell: +94 71 5186770 *
*twitter: **http://twitter.com/ *
*harshathirimannlinked-in: **http:
**//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
*

*Lean . Enterprise . Middleware*


On Tue, Jun 21, 2016 at 9:45 AM, Nuwan Pallewela  wrote:

> Hi Harsha,
>
> On Tue, Jun 21, 2016 at 9:27 AM, Harsha Thirimanna 
> wrote:
>
>> Hi Sohani,
>> Just wanted to know one thing and please make me correct if i am wrong
>> here.
>>
>> Normally, XML elements don't have an order and any implementation should
>> not depend on the order of the elements in XML file except if it has a XSD
>> and saying it as a sequence.
>>
> No. In the specification it is mentioned that XML consider order. And
> there are certain api's which consider the order of the elements. So we
> should to support it in xml.
>
>> So why do we need to concern about the order here. Any special reason for
>> that ?
>>
>>
>> *Harsha Thirimanna*
>> Associate Tech Lead; WSO2, Inc.; http://wso2.com
>> * *
>> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
>> *twitter: **http://twitter.com/ *
>> *harshathirimannlinked-in: **http:
>> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
>> *
>>
>> *Lean . Enterprise . Middleware*
>>
>>
>> On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
>> wrote:
>>
>>> Hi All,
>>>
>>> We are in a process of $subject and the main issue we faced in
>>> generating the json schema was as follows.
>>>
>>> When generating the json schema we mainly convert the xml to json and
>>> the xml to json conversion does not guarantee the order since json object
>>> is an unordered set of name/value pairs [1].
>>>
>>> The main reason is the usage of HashMaps instead of LinkedHashMaps in
>>> instantiating the JSONObjects and we could solve the issue by using the
>>> LinkedHashMaps.
>>>
>>> This issue again occurs in serializing the schema while iterating
>>> through the gmf tree, since we are generating the schema by creating the
>>> JSONObjects and JSONArrays appropriately. We could solve this issue as well
>>> by using the above solution and as a result, the generated tree and the
>>> schema will maintain the order of the XML payload
>>>
>>> [1]
>>> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>>>
>>> Thanks,
>>> Sohani
>>> Sohani Weerasinghe
>>> Senior Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile  : +94 716439774
>>> Blog :http://christinetechtips.blogspot.com/
>>> Twitter  : https://twitter.com/sohanichristine
>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
> Thanks,
> Nuwan
>
> --
> --
>
> *Nuwan Chamara Pallewela*
>
>
> *Software Engineer*
>
> *WSO2, Inc. *http://wso2.com
> *lean . enterprise . middleware*
>
> Email   *nuw...@wso2.com *
> Mobile  *+94719079739 <%2B94719079739>@*
>
>
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Nuwan Pallewela
Hi Harsha,

On Tue, Jun 21, 2016 at 9:27 AM, Harsha Thirimanna  wrote:

> Hi Sohani,
> Just wanted to know one thing and please make me correct if i am wrong
> here.
>
> Normally, XML elements don't have an order and any implementation should
> not depend on the order of the elements in XML file except if it has a XSD
> and saying it as a sequence.
>
No. In the specification it is mentioned that XML consider order. And there
are certain api's which consider the order of the elements. So we should to
support it in xml.

> So why do we need to concern about the order here. Any special reason for
> that ?
>
>
> *Harsha Thirimanna*
> Associate Tech Lead; WSO2, Inc.; http://wso2.com
> * *
> *email: **hars...@wso2.com* * cell: +94 71 5186770 *
> *twitter: **http://twitter.com/ *
> *harshathirimannlinked-in: **http:
> **//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
> *
>
> *Lean . Enterprise . Middleware*
>
>
> On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
> wrote:
>
>> Hi All,
>>
>> We are in a process of $subject and the main issue we faced in generating
>> the json schema was as follows.
>>
>> When generating the json schema we mainly convert the xml to json and the
>> xml to json conversion does not guarantee the order since json object is an
>> unordered set of name/value pairs [1].
>>
>> The main reason is the usage of HashMaps instead of LinkedHashMaps in
>> instantiating the JSONObjects and we could solve the issue by using the
>> LinkedHashMaps.
>>
>> This issue again occurs in serializing the schema while iterating through
>> the gmf tree, since we are generating the schema by creating the
>> JSONObjects and JSONArrays appropriately. We could solve this issue as well
>> by using the above solution and as a result, the generated tree and the
>> schema will maintain the order of the XML payload
>>
>> [1]
>> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>>
>> Thanks,
>> Sohani
>> Sohani Weerasinghe
>> Senior Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile  : +94 716439774
>> Blog :http://christinetechtips.blogspot.com/
>> Twitter  : https://twitter.com/sohanichristine
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
Thanks,
Nuwan

-- 
--

*Nuwan Chamara Pallewela*


*Software Engineer*

*WSO2, Inc. *http://wso2.com
*lean . enterprise . middleware*

Email   *nuw...@wso2.com *
Mobile  *+94719079739@*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Harsha Thirimanna
Hi Sohani,
Just wanted to know one thing and please make me correct if i am wrong here.

Normally, XML elements don't have an order and any implementation should
not depend on the order of the elements in XML file except if it has a XSD
and saying it as a sequence.
So why do we need to concern about the order here. Any special reason for
that ?


*Harsha Thirimanna*
Associate Tech Lead; WSO2, Inc.; http://wso2.com
* *
*email: **hars...@wso2.com* * cell: +94 71 5186770 *
*twitter: **http://twitter.com/ *
*harshathirimannlinked-in: **http:
**//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
*

*Lean . Enterprise . Middleware*


On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe  wrote:

> Hi All,
>
> We are in a process of $subject and the main issue we faced in generating
> the json schema was as follows.
>
> When generating the json schema we mainly convert the xml to json and the
> xml to json conversion does not guarantee the order since json object is an
> unordered set of name/value pairs [1].
>
> The main reason is the usage of HashMaps instead of LinkedHashMaps in
> instantiating the JSONObjects and we could solve the issue by using the
> LinkedHashMaps.
>
> This issue again occurs in serializing the schema while iterating through
> the gmf tree, since we are generating the schema by creating the
> JSONObjects and JSONArrays appropriately. We could solve this issue as well
> by using the above solution and as a result, the generated tree and the
> schema will maintain the order of the XML payload
>
> [1]
> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>
> Thanks,
> Sohani
> Sohani Weerasinghe
> Senior Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Sohani Weerasinghe
Thanks Chanaka for the input

Regards,
Sohani

Sohani Weerasinghe
Senior Software Engineer
WSO2, Inc: http://wso2.com

Mobile  : +94 716439774
Blog :http://christinetechtips.blogspot.com/
Twitter  : https://twitter.com/sohanichristine

On Mon, Jun 20, 2016 at 4:20 PM, Chanaka Fernando  wrote:

> Hi Sohani,
>
> +1 to use LinkedHashMaps instead of HashMaps since former make sure the
> order of the items as you have mentioned. LinkedHashMaps has a higher
> memory footprint but it has a better performance when accessing values in
> the map (refer [1]). If we need a guarantee in the order of items we insert
> into the map, there is no option than using the LinkedHashMap.
>
> [1]
> http://stackoverflow.com/questions/12998568/hashmap-vs-linkedhashmap-performance-in-iteration-over-values
>
> Thanks,
> Chanaka
>
> On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe 
> wrote:
>
>> Hi All,
>>
>> We are in a process of $subject and the main issue we faced in generating
>> the json schema was as follows.
>>
>> When generating the json schema we mainly convert the xml to json and the
>> xml to json conversion does not guarantee the order since json object is an
>> unordered set of name/value pairs [1].
>>
>> The main reason is the usage of HashMaps instead of LinkedHashMaps in
>> instantiating the JSONObjects and we could solve the issue by using the
>> LinkedHashMaps.
>>
>> This issue again occurs in serializing the schema while iterating through
>> the gmf tree, since we are generating the schema by creating the
>> JSONObjects and JSONArrays appropriately. We could solve this issue as well
>> by using the above solution and as a result, the generated tree and the
>> schema will maintain the order of the XML payload
>>
>> [1]
>> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>>
>> Thanks,
>> Sohani
>> Sohani Weerasinghe
>> Senior Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile  : +94 716439774
>> Blog :http://christinetechtips.blogspot.com/
>> Twitter  : https://twitter.com/sohanichristine
>>
>
>
>
> --
> Thank you and Best Regards,
> Chanaka Fernando
> Senior Technical Lead
> WSO2, Inc.; http://wso2.com
> lean.enterprise.middleware
>
> mobile: +94 773337238
> Blog : http://soatutorials.blogspot.com
> LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
> Twitter:https://twitter.com/chanakaudaya
>
>
>
>
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Chanaka Fernando
Hi Sohani,

+1 to use LinkedHashMaps instead of HashMaps since former make sure the
order of the items as you have mentioned. LinkedHashMaps has a higher
memory footprint but it has a better performance when accessing values in
the map (refer [1]). If we need a guarantee in the order of items we insert
into the map, there is no option than using the LinkedHashMap.

[1]
http://stackoverflow.com/questions/12998568/hashmap-vs-linkedhashmap-performance-in-iteration-over-values

Thanks,
Chanaka

On Mon, Jun 20, 2016 at 2:51 PM, Sohani Weerasinghe  wrote:

> Hi All,
>
> We are in a process of $subject and the main issue we faced in generating
> the json schema was as follows.
>
> When generating the json schema we mainly convert the xml to json and the
> xml to json conversion does not guarantee the order since json object is an
> unordered set of name/value pairs [1].
>
> The main reason is the usage of HashMaps instead of LinkedHashMaps in
> instantiating the JSONObjects and we could solve the issue by using the
> LinkedHashMaps.
>
> This issue again occurs in serializing the schema while iterating through
> the gmf tree, since we are generating the schema by creating the
> JSONObjects and JSONArrays appropriately. We could solve this issue as well
> by using the above solution and as a result, the generated tree and the
> schema will maintain the order of the XML payload
>
> [1]
> http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion
>
> Thanks,
> Sohani
> Sohani Weerasinghe
> Senior Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>



-- 
Thank you and Best Regards,
Chanaka Fernando
Senior Technical Lead
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

mobile: +94 773337238
Blog : http://soatutorials.blogspot.com
LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
Twitter:https://twitter.com/chanakaudaya
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] Maintaining the order for XML payloads in JSON schema - Data Mapper

2016-06-20 Thread Sohani Weerasinghe
Hi All,

We are in a process of $subject and the main issue we faced in generating
the json schema was as follows.

When generating the json schema we mainly convert the xml to json and the
xml to json conversion does not guarantee the order since json object is an
unordered set of name/value pairs [1].

The main reason is the usage of HashMaps instead of LinkedHashMaps in
instantiating the JSONObjects and we could solve the issue by using the
LinkedHashMaps.

This issue again occurs in serializing the schema while iterating through
the gmf tree, since we are generating the schema by creating the
JSONObjects and JSONArrays appropriately. We could solve this issue as well
by using the above solution and as a result, the generated tree and the
schema will maintain the order of the XML payload

[1]
http://stackoverflow.com/questions/26034370/inverted-order-of-json-elements-in-java-after-xml-conversion

Thanks,
Sohani
Sohani Weerasinghe
Senior Software Engineer
WSO2, Inc: http://wso2.com

Mobile  : +94 716439774
Blog :http://christinetechtips.blogspot.com/
Twitter  : https://twitter.com/sohanichristine
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev