viscid.vjson module

Wrap python’s json parser enabling comments and trailing commas

Comments are either # or //

viscid.vjson.dump(obj, f, **kwargs)[source]

Wrap Python’s json.dump()

Parameters:
  • obj – some object that Python’s json.dump() understands
  • f – file-like object with a write method
  • **kwargs – passed to Python’s json.dump()
viscid.vjson.dumps(obj, **kwargs)[source]

Wrap Python’s json.dumps()

Parameters:
  • obj – some object that Python’s json.dumps() understands
  • **kwargs – passed to Python’s json.dumps()
viscid.vjson.find_all(s, substrings, start=0, end=None)[source]

Iterate all ocurances of sub in s

Parameters:
  • s (str) – whole string
  • sub (str, list) – substring or list of substrings to find
Yields:

index of start of sub in s

viscid.vjson.load(f, **kwargs)[source]

Read file and pass to loads()

Parameters:
  • f – file-like object with a read method
  • **kwargs – passed to loads()
viscid.vjson.loads(text, **kwargs)[source]

Wrap Python’s json.loads()

Trims out comments and trailing commas first

Parameters:
  • text – json as a string
  • **kwargs – passed to Python’s json.loads()
viscid.vjson.rfind_all(s, substrings, start=0, end=None)[source]

Iterate all ocurances of sub in s

Parameters:
  • s (str) – whole string
  • sub (str, list) – substring or list of substrings to find
Yields:

index of start of sub in s