blob: 8726e873d8b9ca4ee8835e45d14e528b70fe6ecd [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001#/usr/bin/env python
2'''
3Created on 07-Jan-2013
4
5@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
6
7 TestON is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12 TestON is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20
21
22'''
23
24import re
25import json
26class JsonParser:
27 '''
28 Module that parses the response Json to Dictionary and Vice versa.
29 '''
30 def __init__(self) :
31 self.default = ''
32
33 def response_parse(self,json_response):
34 '''
35 This will parse the json formatted string and return content as Dictionary
36 '''
37 response_dict = {}
38 try :
39 response_dict = json.loads(json_response)
40 except :
41 main.log.error("Json Parser is unable to parse the string")
42 return response_dict
43
44 '''
45
46 def dict_json(self,response_dict):
47
48 # This will parse the Python Dictionary and return content as Json string.
49
50 json_response = {}
51 try :
52 json_response = json.dumps(response_dict)
53 except :
54 main.log.error("Json Parser is unable to parse the string")
55 return json_response
56 '''