JSON Path: Nested JSON से values निकालने की व्यावहारिक गाइड
2026-02-26
गहरे nested response में hardcoded access जल्दी जटिल हो जाता है। JSONPath extraction को configurable और maintainable बनाता है।
Basics
$ root है, [*] array elements हैं, ..key recursive search के लिए है।
RFC 9535 ने JSONPath syntax को मानकीकृत किया है।
// $.store.book[*].title → ["A", "B"]Filters
[?(@.price < 10)] array elements को condition के आधार पर filter करता है।
Tools
JavaScript में jsonpath-plus, Python में jsonpath-ng और CLI में jq बहुत उपयोगी हैं।
XPath से अंतर
JSONPath JSON values के लिए है; XML-style attributes/text nodes की अवधारणा यहां नहीं होती।
Best practice
Core production paths को fixed रखें; JSONPath को ops, testing और config extraction में प्रयोग करें।