Question 450
A microservice wants to return a structured JSON object from distinct relational columns using SQL. Which implementation step most directly addresses this requirement?
Explanation
Correct Answer
JSON_OBJECT can construct JSON key-value content in supported SQL engines. Build the documented JSON_OBJECT projection and validate serialized output. API consumer parses keys and types without brittle string concatenation.
Incorrect Answers
Hand-built JSON concatenation can break on escaping, NULL and data types. Use supported JSON_OBJECT with validation.
Forcing every value to a string violates typed JSON consumers. Preserve the expected scalar types in the JSON projection.
A locally parseable JSON string cannot compensate for unsupported SQL syntax. Validate the target engine's JSON_OBJECT support.