Python json.encoder.c_make_encoder() Examples

The following are 14 code examples of json.encoder.c_make_encoder(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module json.encoder , or try the search function .
Example #1
Source File: json_utils.py    From vehicle_counting_tensorflow with MIT License 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #2
Source File: json_utils.py    From ros_people_object_detection_tensorflow with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #3
Source File: json_utils.py    From Person-Detection-and-Tracking with MIT License 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #4
Source File: json_utils.py    From Traffic-Rule-Violation-Detection-System with MIT License 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #5
Source File: json_utils.py    From Gun-Detector with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #6
Source File: json_utils.py    From ros_tensorflow with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #7
Source File: json_utils.py    From BMW-TensorFlow-Training-GUI with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #8
Source File: json_utils.py    From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #9
Source File: json_utils.py    From Elphas with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #10
Source File: json_utils.py    From AniSeg with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #11
Source File: json_utils.py    From MAX-Object-Detector with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #12
Source File: json_utils.py    From g-tensorflow-models with Apache License 2.0 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #13
Source File: json_utils.py    From multilabel-image-classification-tensorflow with MIT License 6 votes vote down vote up
def Dumps(obj, float_digits=-1, **params):
  """Wrapper of json.dumps that allows specifying the float precision used.

  Args:
    obj: The object to dump.
    float_digits: The number of digits of precision when writing floats out.
    **params: Additional parameters to pass to json.dumps.

  Returns:
    output: JSON string representation of obj.
  """
  original_encoder = encoder.FLOAT_REPR
  original_c_make_encoder = encoder.c_make_encoder
  if float_digits >= 0:
    encoder.FLOAT_REPR = lambda o: format(o, '.%df' % float_digits)
    encoder.c_make_encoder = None
  try:
    output = json.dumps(obj, **params)
  finally:
    encoder.FLOAT_REPR = original_encoder
    encoder.c_make_encoder = original_c_make_encoder

  return output 
Example #14
Source File: test_speedups.py    From Computable with MIT License 5 votes vote down vote up
def test_make_encoder(self):
        self.assertRaises(TypeError, encoder.c_make_encoder,
            None,
            "\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
            None)