D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
lib
/
python3.9
/
site-packages
/
google
/
protobuf
/
__pycache__
/
Filename :
json_format.cpython-39.pyc
back
Copy
a ԜiM� � @ s d Z dZzddlmZ W n ey6 ddlmZ Y n0 ddlZddlZddlZddl m Z ddlZddlZddl Z ddlmZ ddlmZ ddlmZ d Zeejjejjejjejjg�Zeejjejjg�Zeejjejjg�Zd ZdZ dZ!e�"e �#d ��Z$e�"d�Z%G dd� de&�Z'G dd� de'�Z(G dd� de'�Z)d?dd�Z*d@dd�Z+dd� Z,G dd� de-�Z.dd � Z/d!d"� Z0d#d$� Z1dAd&d'�Z2dBd(d)�Z3e j4e5f Z6G d*d+� d+e-�Z7dCd,d-�Z8d.d/� Z9d0d1� Z:d2d3� Z;d4d5gd6d7gd6d7gd8d9gd:d;gd6d7gd<d=gd>�Z<dS )Dat Contains routines for printing protocol messages in JSON format. Simple usage example: # Create a proto object and serialize it to a json format string. message = my_proto_pb2.MyMessage(foo='bar') json_string = json_format.MessageToJson(message) # Parse a json format string to proto object. message = json_format.Parse(json_string, my_proto_pb2.MyMessage()) zjieluo@google.com (Jie Luo)� )�OrderedDictN)�methodcaller)� type_checkers)� descriptor)�symbol_databasez%Y-%m-%dT%H:%M:%SZInfinityz -InfinityZNaNzF[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]z\[[a-zA-Z0-9\._]*\]$c @ s e Zd ZdZdS )�Errorz'Top-level module error for json_format.N��__name__� __module__�__qualname__�__doc__� r r �?/usr/lib/python3.9/site-packages/google/protobuf/json_format.pyr X s r c @ s e Zd ZdZdS )�SerializeToJsonErrorz&Thrown if serialization to JSON fails.Nr r r r r r \ s r c @ s e Zd ZdZdS )� ParseErrorz Thrown in case of parsing error.Nr r r r r r ` s r F� c C s t |||||d�}|�| ||�S )aR Converts protobuf message to JSON format. Args: message: The protocol buffers message instance to serialize. including_default_value_fields: If True, singular primitive fields, repeated fields, and map fields will always be serialized. If False, only serialize non-empty fields. Singular message fields and oneof fields are not affected by this option. preserving_proto_field_name: If True, use the original proto field names as defined in the .proto file. If False, convert the field names to lowerCamelCase. indent: The JSON object will be pretty-printed with this indent level. An indent level of 0 or negative will only insert newlines. sort_keys: If True, then the output will be sorted by field names. use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. Returns: A string containing the JSON formatted protocol buffer message. ��float_precision)�_Printer�ToJsonString) �message�including_default_value_fields�preserving_proto_field_name�indent� sort_keys�use_integers_for_enums�descriptor_poolr �printerr r r � MessageToJsond s �r c C s t |||||d�}|�| �S )a� Converts protobuf message to a dictionary. When the dictionary is encoded to JSON, it conforms to proto3 JSON spec. Args: message: The protocol buffers message instance to serialize. including_default_value_fields: If True, singular primitive fields, repeated fields, and map fields will always be serialized. If False, only serialize non-empty fields. Singular message fields and oneof fields are not affected by this option. preserving_proto_field_name: If True, use the original proto field names as defined in the .proto file. If False, convert the field names to lowerCamelCase. use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. Returns: A dict representation of the protocol buffer message. r )r �_MessageToJsonObject)r r r r r r r r r r � MessageToDict� s �r c C s"