An online XML to JSON conversion and validation tool
You can see on live demo here: http://smksamuka.pythonanywhere.com/
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
Access the URL from your local: http://127.0.0.1:8000/connected/
And enjoy it! 🎉
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"}]}]}
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