loads.pyx 479 B

1234567891011121314
  1. from libcpp cimport bool
  2. cdef extern from "library/python/json/loads.h":
  3. object LoadJsonFromString(const char*, size_t, bool internKeys, bool internVals, bool mayUnicode) except +
  4. def loads(s, intern_keys = False, intern_vals = False, may_unicode = False):
  5. if isinstance(s, unicode):
  6. s = s.encode('utf-8')
  7. try:
  8. return LoadJsonFromString(s, len(s), intern_keys, intern_vals, may_unicode)
  9. except Exception as e:
  10. raise ValueError(str(e))