Module: A2A::Extensions::JSONDeserialization::ClassMethods

Defined in:
lib/a2a/extensions/json_deserialization.rb

Overview

Class methods added to the class that includes JsonDeserialization

Instance Method Summary collapse

Instance Method Details

#from_json(json) ⇒ ProtocolStruct

Creates a new instance from a JSON string

Examples:

Create a Google Maps Agent Card from JSON

json_string = <<~JSON
  {
    "name": "Google Maps Agent",
    "description": "Plan routes, remember places, and generate directions",
    "url": "https://maps-agent.google.com",
    "provider": {
      "organization": "Google",
      "url": "https://google.com"
    },
    "version": "1.0.0",
    "capabilities": {
      "streaming": true,
      "pushNotifications": false
    },
    "skills": [
      {
        "id": "route-planner",
        "name": "Route planning",
        "description": "Helps plan routing between two locations"
      }
    ]
  }
JSON
agent_card = A2A::AgentCard.from_json(json_string)

Parameters:

  • json (String)

    JSON string to parse

Returns:

  • (ProtocolStruct)

    A new instance of the appropriate class



47
48
49
# File 'lib/a2a/extensions/json_deserialization.rb', line 47

def from_json(json)
  new(JSON.parse(json))
end