MCPcopy
hub / github.com/tkfy920/qstock / __init__

Method __init__

data/demjson.py:3479–3516  ·  view source on GitHub ↗

Creates a JSON encoder/decoder object. You may pass encoding and decoding options either by passing an argument named 'json_options' with an instance of a json_options class; or with individual keyword/values that will be used to initialize a new json_options object.

(self, **kwargs)

Source from the content-addressed store, hash-verified

3477 'encode_sequence', 'encode_bytes', 'encode_default')
3478
3479 def __init__(self, **kwargs):
3480 """Creates a JSON encoder/decoder object.
3481
3482 You may pass encoding and decoding options either by passing
3483 an argument named 'json_options' with an instance of a
3484 json_options class; or with individual keyword/values that will
3485 be used to initialize a new json_options object.
3486
3487 You can also set hooks by using keyword arguments using the
3488 hook name; e.g., encode_dict=my_hook_func.
3489
3490 """
3491 import sys, unicodedata, re
3492
3493 kwargs = kwargs.copy()
3494 # Initialize hooks
3495 for hookname in self.all_hook_names:
3496 if hookname in kwargs:
3497 self.set_hook(hookname, kwargs[hookname])
3498 del kwargs[hookname]
3499 else:
3500 self.set_hook(hookname, None)
3501
3502 # Set options
3503 if 'json_options' in kwargs:
3504 self._options = kwargs['json_options']
3505 else:
3506 self._options = json_options(**kwargs)
3507
3508 # The following is a boolean map of the first 256 characters
3509 # which will quickly tell us which of those characters never
3510 # need to be escaped.
3511
3512 self._asciiencodable = \
3513 [32 <= c < 128 \
3514 and chr(c) not in self._rev_escapes \
3515 and not unicodedata.category(chr(c)) in ['Cc', 'Cf', 'Zl', 'Zp']
3516 for c in range(0, 256)]
3517
3518 @property
3519 def options(self):

Callers 3

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 3

set_hookMethod · 0.95
json_optionsClass · 0.85
copyMethod · 0.45

Tested by

no test coverage detected