Query und extract data von JSON Verwendung JSONPath expressions
Features
- Erweitert Query Syntax: Support full JSONPath syntax einschließlich wildcards (*), recursive descent (..), array slicing ([Starten:end]), filters ([?(@.price < 10)]), et plusieurs Chemin selectors
- Path Expression Templates: Pre-built templates für common queries: root access ($), direct child ($.key), array Elemente ($.arr[*]), filtered Elemente ($.arr[?(@.id)]), recursive Suchen ($..key)
- Real-Time Preview: Execute queries instantly mit syntax-highlighted JSON Eingabe et Ausgabe, Anzeigen matching Chemins, display Ergebnis count, et highlight matched nodes in source JSON
- Result Export: Export query Ergebnisse als JSON (array oder single Wert), CSV für tabular data, oder formatiert text mit one-Klicken Kopieren und Herunterladen options
Usage Guide
- Eingabe JSON Daten: Einfügen oder Hochladen JSON data you want zu query
- Write JSONPath: Eingeben JSONPath expression oder verwenden templates für common patterns
- Execute Query: Run query to see matching results mit syntax highlighting
- Exportieren Results: Kopieren or Herunterladen extracted data in votre preferred Format
Technical Details
JSONPath Syntax
JSONPath expressions Starten mit $ (root object) and use dot notation ($.property) or bracket notation ($['property']) für access. Child nodes use . separator ($.store.book), arrays use [index] or [*] für Alle Elemente. Array slicing [Starten:end:Schritt] extracts ranges like [0:3] (Erste 3 Elemente) or [-1] (Letzte Element). Recursive descent operator .. searches Alle Niveaux: $..author finds Alle author properties regardless of nesting depth. Union operator [,] selects plusieurs Elemente: $[0,2,5] gets specific array indices.
Filter Expressions
Filters use [?(@.condition)] syntax to Auswählen Elemente matching criteria. @ represents current node in iteration. Comparison operators: ==, !=, <, <=, >, >=. Logical operators: && (et), || (or), ! (not). Examples: [?(@.price < 10)] selects Elemente mit price under 10; [?(@.Catégorie == 'fiction' && @.price < 20)] combines conditions. Regular expression matching: [?(@.Name =~ /pattern/)] filters by regex. Filters can reference root mit $ für comparisons across hierarchy: [?(@.price < $.maxPrice)].
Implementation Variants
JSONPath has plusieurs implementations mit slight syntax variations: Goessner's original (JavaScript), Jayway (Java), jsonpath-ng (Python). Differences include Filtern operators (some use @ vs $), regex Support, script expressions, and function extensions. Some implementations Hinzufügen functions like @.length, @.min(), @.max() für aggregation. Script expressions [(@.price * @.quantity)] enable calculations. Parent operator ^ and current Chemin ~ provide context. Always check target implementation's Dokumentation für supported Funktionen and syntax quirks.
Frequently Asked Questions
- Warum ist das Ergebnis leer?
- Stellen Sie sicher, dass der Pfad mit $ beginnt, Array-Indizes gültig sind und Feldnamen exakt übereinstimmen. Testen Sie zuerst mit einem einfachen Pfad.
- Wie finde ich einen Schlüssel in beliebiger Tiefe?
- Verwenden Sie rekursiven Abstieg: $..author findet author auf allen Ebenen.
- Wie schreibe ich Filtern?
- Nutzen Sie [?(@.price < 10)]. @ steht für das aktuelle Element. Bedingungen lassen sich mit && und || kombinieren.
- Unterschied zwischen leerem Ergebnis und null?
- Leer bedeutet keine Übereinstimmung; null bedeutet, der gefundene Wert ist null. Prüfen Sie Quelldaten und Ausdruck.
- Performance bei großen JSON-Dateien?
- Vermeiden Sie exzessives ..; grenzen Sie zuerst ein und filtern Sie danach. Erwägen Sie Streaming oder serverseitige Verarbeitung.
Related Documentation
- JSONPath Specification - Goessner - Original JSONPath proposal und Syntax definition
- JSONPath Online Evaluator - Interactive JSONPath tester mit expression Dokumentation
- RFC 9535 - JSONPath Standard - IETF standardization effürt für JSONPath query Sprache
- jsonpath-ng Dokumentation - Python JSONPath implementation mit extended features
- Jayway JSONPath (Java) - Popular Java implementation mit filter expressions