Bird
0
0

Which PostgreSQL function can be used to convert a text string into JSON format when inserting?

easy📝 Conceptual Q2 of 15
PostgreSQL - JSON and JSONB
Which PostgreSQL function can be used to convert a text string into JSON format when inserting?
Ato_json()
Bjson_parse()
Cjsonb_to_text()
Dcast_to_json()
Step-by-Step Solution
Solution:
  1. Step 1: Identify PostgreSQL JSON conversion functions

    PostgreSQL provides to_json() to convert various data types into JSON format.
  2. Step 2: Verify function correctness

    Functions like json_parse(), jsonb_to_text(), and cast_to_json() do not exist in PostgreSQL.
  3. Final Answer:

    to_json() -> Option A
  4. Quick Check:

    Convert text to JSON = to_json() [OK]
Quick Trick: Use to_json() to convert text or values to JSON format [OK]
Common Mistakes:
  • Using non-existent functions
  • Confusing jsonb and json functions
  • Trying to cast text directly without function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes