Skip to content

Commit 0e12c4c

Browse files
committed
Fixes #46 Implements XML to JSON conversions with lib supports
1 parent 9c81bf0 commit 0e12c4c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

loklak.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
import re
99
import requests
10+
from xmljson import badgerfish as bf
11+
from json import dumps
1012

1113

1214
class Loklak(object):
@@ -54,6 +56,17 @@ def status(self):
5456
return_to_user = {}
5557
return json.dumps(return_to_user)
5658

59+
def xmlToJson(self, xmlData = None):
60+
"""Converts XML to JSON as the service"""
61+
jsonData = ''
62+
if xmlData:
63+
jsonData = dumps(bf.data(fromstring(xmlData)))
64+
return jsonData
65+
66+
def csvToJson(self):
67+
"""Converts CSV to JSON as the service"""
68+
69+
5770
def hello(self):
5871
"""Gives a hello"""
5972
hello_application = 'api/hello.json'

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
asyncoro==3.5
22
requests==2.8.1
33
wsgiref==0.1.2
4+
xmljson==0.1.6
5+

0 commit comments

Comments
 (0)