osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

XML to JSON conversion - convert attributes #240

Open greenlaw110 opened 3 years ago

greenlaw110 commented 3 years ago

Given XML file as

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd"
         updateCheck="true"
         monitoring="autodetect"
         dynamicConfig="true">

    <cache name="charityCache"
           maxEntriesLocalHeap="1000"
           eternal="false"
           timeToIdleSeconds="2" timeToLiveSeconds="20"
           memoryStoreEvictionPolicy="LFU"
           transactionalMode="off">
        <persistence strategy="none" />
    </cache>
    <cache name="charityTagsCache"
           maxEntriesLocalHeap="1000"
           eternal="false"
           timeToIdleSeconds="20" timeToLiveSeconds="60"
           memoryStoreEvictionPolicy="LFU"
           transactionalMode="off">
        <persistence strategy="none" />
    </cache>
</ehcache>

At the moment it misses attribute info when converted into JSON via:

$.convert(dom).to(JSONObject.class);

This CR is to add support to XML attributes into target JSON object