GithubHelp home page GithubHelp logo

django_xml2json's Introduction

django_xml2json

An online XML to JSON conversion and validation tool

Live demo ๐Ÿ”

You can see on live demo here: http://smksamuka.pythonanywhere.com/

.docs/django_xml2json-use.gif

Install ๐Ÿง‘๐Ÿฝโ€๐Ÿ’ป

Execute commands on terminal:

# clone this repository
git clone https://github.com/samukasmk/django_xml2json.git

# access new folder
cd django_xml2json

# create new virtualenv
python3 -m venv ./venv
source ./venv/bin/activate

# install required libraries
pip install -r requirements.txt

# run the webserver (in developement mode)
./manage.py runserver

.docs/django_xml2json-install.gif

Using web app ๐Ÿ“ƒ

Access the URL from your local: http://127.0.0.1:8000/connected/

And enjoy it! ๐ŸŽ‰

Parsing by Rest Framework API ๐ŸŒ

Create a sample file:

cat > address.json << EOF
<?xml version="1.0"?>
<Root>
    <Address>
        <StreetLine1>123 Main St.</StreetLine1>
        <StreetLine2>Suite 400</StreetLine2>
        <City>San Francisco</City>
        <State>CA</State>
        <PostCode>94103</PostCode>
    </Address>
    <Address>
        <StreetLine1>400 Market St.</StreetLine1>
        <City>San Francisco</City>
        <State>CA</State>
        <PostCode>94108</PostCode>
    </Address>
</Root>
EOF

Upload with curl command:

curl -F [email protected] http://127.0.0.1:8000/api/converter/convert/       
{"Root":[{"Address":[{"StreetLine1":"123 Main St."},{"StreetLine2":"Suite 400"},{"City":"San Francisco"},{"State":"CA"},{"PostCode":"94103"}]},{"Address":[{"StreetLine1":"400 Market St."},{"City":"San Francisco"},{"State":"CA"},{"PostCode":"94108"}]}]}

Testing ๐Ÿ› ๏ธ

You can run tests my django manage command:

./manage.py test
Found 22 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
......................
----------------------------------------------------------------------
Ran 22 tests in 0.088s

OK
Destroying test database for alias 'default'...

Or run a specific test with python unittest library

DJANGO_SETTINGS_MODULE=exercise.tests_settings python -m unittest -k xml_converter.tests.XMLConversionTestCase.test_connected_convert_addresses
.
----------------------------------------------------------------------
Ran 1 test in 0.195s

OK

django_xml2json's People

Contributors

samukasmk avatar

Stargazers

 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.