Telegram::ResponseParser
Comprehensive response parsing utilities for Telegram Bot API
This module provides robust parsing capabilities for all types of responses from the Telegram Bot API, including complex nested structures, arrays, and optional fields. It includes comprehensive error handling and validation.
Features
- Primitive type parsing with null safety
- Nested array parsing (Array(Array(MessageEntity)))
- Hash and NamedTuple response parsing
- Mixed type array parsing with dynamic type detection
- Recursive parsing for arbitrary depth structures
- Comprehensive error handling and validation
Example
class MyClient
include Telegram::ResponseParser
def some_method
response = HTTP::Client.get("...")
json_response = JSON.parse(response.body)
# Parse complex response type
result = parse_response(json_response, "Array(Array(MessageEntity))")
end
end