MCPcopy Index your code
hub / github.com/hugapi/hug / JSON

Class JSON

hug/types.py:365–384  ·  view source on GitHub ↗

Accepts a JSON formatted data structure

Source from the content-addressed store, hash-verified

363
364
365class JSON(Type):
366 """Accepts a JSON formatted data structure"""
367
368 __slots__ = ()
369
370 def __call__(self, value):
371 if type(value) in (str, bytes):
372 try:
373 return json_converter.loads(value)
374 except Exception:
375 raise ValueError("Incorrectly formatted JSON provided")
376 if type(value) is list:
377 # If Falcon is set to comma-separate entries, this segment joins them again.
378 try:
379 fixed_value = ",".join(value)
380 return json_converter.loads(fixed_value)
381 except Exception:
382 raise ValueError("Incorrectly formatted JSON provided")
383 else:
384 return value
385
386
387class Multi(Type):

Callers 1

types.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected