Git Product home page Git Product logo

json-lib's Introduction

Json-lib with auto-expansion of properties

The XML serialization is extended to handle automatic expansion of properties for arrays that contains objects.

Source file to be serialized to and from JSON

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document DOMVersion="8.0" Self="d">
    <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27">
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
            <rdf:Description rdf:about=""
                             xmlns:dc="http://purl.org/dc/elements/1.1/">
                <dc:format>application/x-indesign</dc:format>
            </rdf:Description>
            <rdf:Description rdf:about=""
                             xmlns:xmp="http://ns.adobe.com/xap/1.0/">
                <xmp:CreatorTool>Adobe InDesign CS6 (Macintosh)</xmp:CreatorTool>
            </rdf:Description>
            <rdf:Description rdf:about=""
                             xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
                <xmpMM:InstanceID>xmp.iid:D093CC710A2068118083AFA2F0AAE3ED</xmpMM:InstanceID>
            </rdf:Description>
        </rdf:RDF>
    </x:xmpmeta>
</Document>

file.xml

Original json-lib

This code

XMLSerializer serializer = new XMLSerializer();
serializer.setTypeHintsEnabled(false);

JSON jsonRepresentation = serializer.readFromFile( "file.xml" );

String xml = serializer.write( jsonRepresentation );
System.out.writeToReadme(xml)

will render:

<o DOMVersion="8.0" Self="d">
    <x:xmpmeta xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27" xmlns:x="adobe:ns:meta/">
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
            <rdf:Description>
                <e about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
                    <dc:format>application/x-indesign</dc:format>
                </e>
                <e about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
                    <xmp:CreatorTool>Adobe InDesign CS6 (Macintosh)</xmp:CreatorTool>
                </e>
                <e about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
                    <xmpMM:InstanceID>xmp.iid:D093CC710A2068118083AFA2F0AAE3ED</xmpMM:InstanceID>
                </e>
            </rdf:Description>
        </rdf:RDF>
    </x:xmpmeta>
</o>

AutoExpand

This code

XMLSerializer serializer = new XMLSerializer();
serializer.setTypeHintsEnabled(false);
serializer.setPerformAutoExpansion(true);

JSON jsonRepresentation = serializer.readFromFile( "file.xml" );

String xml = serializer.write( jsonRepresentation );
System.out.writeToReadme(xml)

will render:

<o DOMVersion="8.0" Self="d">
<x:xmpmeta xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27" xmlns:x="adobe:ns:meta/">
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
            <dc:format>application/x-indesign</dc:format>
        </rdf:Description>
        <rdf:Description about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
            <xmp:CreatorTool>Adobe InDesign CS6 (Macintosh)</xmp:CreatorTool>
        </rdf:Description>
        <rdf:Description about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
            <xmpMM:InstanceID>xmp.iid:D093CC710A2068118083AFA2F0AAE3ED</xmpMM:InstanceID>
        </rdf:Description>
    </rdf:RDF>
</x:xmpmeta>
</o>

json-lib's People

Contributors

aalmiray avatar hertzsprung avatar kohsuke avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.