MCPcopy Create free account
hub / github.com/apache/trafficserver / parse_json

Function parse_json

plugins/traffic_dump/post_process.py:200–223  ·  view source on GitHub ↗

Open and parse the replay_file. Args: replay_file (string) The file with JSON content to parse. Return: The json package parsed JSON file or None if there was a problem parsing the file.

(replay_file)

Source from the content-addressed store, hash-verified

198
199
200def parse_json(replay_file):
201 """ Open and parse the replay_file.
202
203 Args:
204 replay_file (string) The file with JSON content to parse.
205
206 Return:
207 The json package parsed JSON file or None if there was a problem
208 parsing the file.
209 """
210 try:
211 fd = open(replay_file, 'r')
212 except Exception as e:
213 logging.exception("Failed to open %s.", replay_file)
214 raise ParseJSONError(e)
215
216 try:
217 parsed_json = json.load(fd)
218 except Exception as e:
219 message = e.msg.split(':')[0]
220 logging.error("Failed to load %s as a JSON object: %s", replay_file, e)
221 raise ParseJSONError(message)
222
223 return parsed_json
224
225
226def readAndCombine(replay_dir, num_sessions_per_file, indent, fabricate_proxy_requests, out_dir):

Callers 1

readAndCombineFunction · 0.85

Calls 4

ParseJSONErrorClass · 0.85
loadMethod · 0.45
splitMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected