JSON provides a language-neutral response format for APIs that must return structured results to JavaScript, Python, Swift, and other clients. Its text-based, human-readable representation supports straightforward parsing and debugging while preserving objects, arrays, nested values, strings, and numbers. section 2.3.4
Use JSON to keep API boundaries predictable:
- Return fields such as a category and confidence value in one structured object. section 2.3.4
- Keep the API response format consistent for generated files by returning an object-storage URL instead of embedding arbitrary content. section 2.3.4
- Send request data in a POST body, avoiding GET URL-length limits and reducing exposure of sensitive values in server logs. section 2.3.4
Categorization response
A synchronous image-categorization endpoint can return {"category": "electronics", "confidence": 0.95}. Any HTTP client can parse the object and use its fields. section 2.3.4
service SessionService {
rpc GetOrCreateSession(GetOrCreateSessionRequest)
returns (GetOrCreateSessionResponse);
rpc AddMessages(AddMessagesRequest)
returns (AddMessagesResponse);
}
message GetOrCreateSessionRequest {
string user_id = 1;
optional string session_id = 2;
}Contrast JSON at external API boundaries with Protocol Buffers used for compact, schema-defined internal service communication. section 2.4.2









































