{"id":1553,"library":"microsoft-kiota-serialization-json","title":"Microsoft Kiota JSON Serialization","description":"microsoft-kiota-serialization-json provides JSON serialization and deserialization capabilities for Kiota-generated Python SDKs. It includes factories for creating JSON serialization writers and parse nodes, enabling the conversion of `Parsable` objects to and from JSON format. The library is part of the larger Microsoft Kiota ecosystem and is currently at version 1.10.1, with frequent synchronized releases across its components.","status":"active","version":"1.10.1","language":"python","source_language":"en","source_url":"https://github.com/microsoft/kiota-python","tags":["microsoft","kiota","serialization","json","openapi","sdk","codegen"],"install":[{"cmd":"pip install microsoft-kiota-serialization-json","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides core interfaces like Parsable, ParseNode, and SerializationWriter which are fundamental to the serialization process.","package":"microsoft-kiota-abstractions","optional":false}],"imports":[{"wrong":"from kiota_serialization_json import JsonSerializationWriterFactory","symbol":"JsonSerializationWriterFactory","correct":"from kiota_serialization_json import JsonSerializationWriterFactory"},{"symbol":"JsonParseNodeFactory","correct":"from kiota_serialization_json import JsonParseNodeFactory"},{"symbol":"VERSION","correct":"from kiota_serialization_json import VERSION"}],"quickstart":{"code":"import io\nfrom typing import Callable, Dict, Optional\nfrom uuid import UUID\n\nfrom microsoft_kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter\nfrom microsoft_kiota_serialization_json import JsonParseNodeFactory, JsonSerializationWriterFactory\n\nclass MyModel(Parsable):\n    \"\"\"A simple model for demonstration.\"\"\"\n    def __init__(self) -> None:\n        self._id: Optional[UUID] = None\n        self._name: Optional[str] = None\n        self.additional_data: Dict[str, object] = {}\n\n    @property\n    def id(self) -> Optional[UUID]:\n        return self._id\n\n    @id.setter\n    def id(self, value: Optional[UUID]) -> None:\n        self._id = value\n\n    @property\n    def name(self) -> Optional[str]:\n        return self._name\n\n    @name.setter\n    def name(self, value: Optional[str]) -> None:\n        self._name = value\n\n    def get_field_deserializers(self) -> Dict[str, Callable[[ParseNode], None]]:\n        \"\"\"Gets the deserialization information for the current model.\"\"\"\n        return {\n            \"id\": lambda n: setattr(self, 'id', n.get_uuid_value()),\n            \"name\": lambda n: setattr(self, 'name', n.get_str_value()),\n        }\n\n    def serialize(self, writer: SerializationWriter) -> None:\n        \"\"\"Serializes properties of the current model into a writer.\"\"\"\n        writer.write_uuid_value(\"id\", self.id)\n        writer.write_str_value(\"name\", self.name)\n        writer.write_additional_data_value(self.additional_data)\n\n# --- Usage Example ---\n\n# 1. Create a model instance\nmy_object = MyModel()\nmy_object.id = UUID(\"12345678-1234-5678-1234-567812345678\")\nmy_object.name = \"Test Item\"\nmy_object.additional_data[\"status\"] = \"active\"\n\n# 2. Serialize the model to JSON\nwriter_factory = JsonSerializationWriterFactory()\n# Use 'application/json' for JSON content type\nwith writer_factory.get_serialization_writer(\"application/json\") as writer:\n    # Pass None as the key for the root object\n    writer.write_object_value(None, my_object)\n    serialized_content_bytes = writer.get_serialized_content()\n\nprint(\"Serialized JSON:\")\nprint(serialized_content_bytes.decode('utf-8'))\n\n# 3. Deserialize the JSON back into a model instance\nparse_node_factory = JsonParseNodeFactory()\nwith parse_node_factory.get_parse_node(\"application/json\", serialized_content_bytes) as parse_node:\n    deserialized_object = parse_node.get_object_value(MyModel)\n\nprint(\"\\nDeserialized object:\")\nprint(f\"ID: {deserialized_object.id}\")\nprint(f\"Name: {deserialized_object.name}\")\nprint(f\"Additional data: {deserialized_object.additional_data}\")\n\n# Verify deserialization\nassert deserialized_object.id == my_object.id\nassert deserialized_object.name == my_object.name\nassert deserialized_object.additional_data[\"status\"] == my_object.additional_data[\"status\"]\nprint(\"\\nSerialization and deserialization successful!\")","lang":"python","description":"This example demonstrates how to serialize a `Parsable` object to JSON and then deserialize it back using `JsonSerializationWriterFactory` and `JsonParseNodeFactory`. It defines a simple `MyModel` class implementing the `Parsable` interface from `microsoft-kiota-abstractions`."},"warnings":[{"fix":"Upgrade your Python environment to version 3.10, 3.11, 3.12, or 3.13.","message":"Starting with version 1.10.0, support for Python 3.9 has been dropped. Ensure your environment uses Python 3.10 or newer.","severity":"breaking","affected_versions":">=1.10.0"},{"fix":"Ensure that your data models implement the `Parsable` interface correctly. For general JSON handling, consider `json` or `pydantic`.","message":"This library is designed specifically for serializing and deserializing models that implement the `microsoft_kiota_abstractions.serialization.Parsable` interface, typically generated by the Kiota OpenAPI SDK generator. It is not intended as a general-purpose JSON serialization library for arbitrary Python objects.","severity":"gotcha","affected_versions":"All"},{"fix":"For a direct object JSON output, pass `None` or an empty string as the key to `write_object_value` when serializing the top-level object. E.g., `writer.write_object_value(None, my_model)`.","message":"When serializing a root object using `writer.write_object_value()`, the key parameter should typically be `None` or an empty string, especially if the resulting JSON should be a single object. Providing a non-None, non-empty key will wrap the object under that key.","severity":"gotcha","affected_versions":"All"},{"fix":"Verify that `microsoft-kiota-abstractions` is present in your environment (`pip show microsoft-kiota-abstractions`). If not, explicitly install it (`pip install microsoft-kiota-abstractions`).","message":"This library relies heavily on `microsoft-kiota-abstractions`. If you install `microsoft-kiota-serialization-json` directly, ensure `microsoft-kiota-abstractions` is also installed (it's a dependency, but manual inspection might be needed if dependency resolution issues arise).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'1.10.1':59 'across':64 'capabl':15 'codegen':73 'compon':66 'convers':35 'creat':26 'current':56 'deseri':14 'ecosystem':53 'enabl':33 'factori':24 'format':43 'frequent':61 'generat':19 'includ':23 'json':3,9,11,27,42,70 'kiota':2,7,18,52,68 'kiota-gener':17 'larger':50 'librari':45 'microsoft':1,6,51,67 'microsoft-kiota-serialization-json':5 'node':32 'object':38 'openapi':71 'pars':31 'parsabl':37 'part':47 'provid':10 'python':20 'releas':63 'sdk':72 'sdks':21 'serial':4,8,12,28,69 'synchron':62 'version':58 'writer':29","created_at":"2026-04-09T03:53:04.188382+00:00","updated_at":"2026-04-16T16:31:55.409975+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'JsonSerializationWriterFactory' from 'kiota_serialization_json' (/tmp/tmpb75x35vy/venv/lib/python3.12/site-packages/kiota_serialization_json/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":0,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.10.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/microsoft/kiota#readme","docs":"https://learn.microsoft.com/openapi/kiota/","changelog":null,"pypi":"https://pypi.org/project/microsoft-kiota-serialization-json/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","http-networking","azure"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":"stale"}}