Bird
0
0

Why does the ->> operator return text instead of JSON in PostgreSQL?

hard📝 Conceptual Q10 of 15
PostgreSQL - JSON and JSONB
Why does the ->> operator return text instead of JSON in PostgreSQL?
ABecause it returns the entire JSON object as text
BBecause it extracts the JSON field and automatically converts it to text
CBecause it deletes the JSON key after extraction
DBecause it only works on JSON arrays, not objects
Step-by-Step Solution
Solution:
  1. Step 1: Understand purpose of ->> operator

    The ->> operator extracts a JSON field and returns its value as plain text, not JSON.
  2. Step 2: Reason why text is returned

    This is because it automatically converts the JSON value to text for easier use in SQL queries.
  3. Final Answer:

    Because it extracts the JSON field and automatically converts it to text -> Option B
  4. Quick Check:

    ->> returns text by converting JSON value [OK]
Quick Trick: ->> extracts and converts JSON value to text [OK]
Common Mistakes:
  • Thinking ->> deletes keys
  • Assuming ->> only works on arrays
  • Believing ->> returns JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes