jsonyx.detect_encoding

jsonyx.detect_encoding(b)

Detect the JSON encoding.

Parameters:

b (bytearray | bytes) – a JSON string

Returns:

str – the detected encoding

Example:
>>> import jsonyx as json
>>> b = b'\x00"\x00f\x00o\x00o\x00"'
>>> b.decode(json.detect_encoding(b))
'"foo"'

Note

Supports only "utf-8", "utf-8-sig", "utf-16", "utf-16-be", "utf-16-le", "utf-32", "utf-32-be" and "utf-32-le".