Bird
0
0

Which of the following is the correct syntax to represent a filter for 'price greater than 50' in a JSON query?

easy📝 Conceptual Q3 of 15
LLD - Design — Hotel Booking System
Which of the following is the correct syntax to represent a filter for 'price greater than 50' in a JSON query?
A{ \"price\": { \"$lt\": 50 } }
B{ \"price\": { \"$eq\": 50 } }
C{ \"price\": 50 }
D{ \"price\": { \"$gt\": 50 } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand JSON filter operators

    In JSON queries, "$gt" means 'greater than', "$lt" means 'less than', "$eq" means 'equals'.
  2. Step 2: Match operator to condition

    For 'price greater than 50', "$gt" operator is correct.
  3. Final Answer:

    { "price": { "$gt": 50 } } -> Option D
  4. Quick Check:

    Greater than filter = "$gt" [OK]
Quick Trick: Use "$gt" for greater than in JSON filters [OK]
Common Mistakes:
  • Using "$lt" instead of "$gt"
  • Using equality operator for range filters
  • Omitting operator and just giving value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes