Question 390
An API expects a single relational row converted into a JSON object with named fields. What should the SQL developer do FIRST to address the specific issue?
Explanation
Correct Answer
Use JSON_OBJECT with explicit key/value expressions where supported. This targets the primary issue because JSON_OBJECT constructs a JSON object from typed expressions instead of fragile string concatenation. Verification: A JSON parser reads the intended named fields and escaped text. Prevent recurrence: Pin feature availability to the deployed SQL engine.
Incorrect Answers
JSON_VALUE extracts a scalar path, while OPENJSON can shred collections.
Using MATCH with explicit edge direction and aliases for the required path would not correct an API expects a single relational row converted into a JSON object with named fields. Use JSON_OBJECT with explicit key/value expressions where supported.
NULL in a NOT IN subquery can yield UNKNOWN and unexpectedly filter all rows.