mirror of
				https://github.com/stedolan/jq.git
				synced 2024-05-11 05:55:39 +00:00 
			
		
		
		
	Document path(path_expression) builtin
				
					
				
			This commit is contained in:
		@@ -618,6 +618,33 @@ sections:
 | 
			
		||||
            input: '[[0,1], ["a","b","c"]]'
 | 
			
		||||
            output: ['[false, true]']
 | 
			
		||||
 | 
			
		||||
      - title: "`path(path_expression)`"
 | 
			
		||||
        body: |
 | 
			
		||||
 | 
			
		||||
          Outputs array representations of the given path expression
 | 
			
		||||
          in `.`.  The outputs are arrays of strings (keys in objects0
 | 
			
		||||
          and/or numbers (array indices.
 | 
			
		||||
 | 
			
		||||
          Path expressions are jq expressions like `.a`, but also `.[]`.
 | 
			
		||||
          There are two types of path expressions: ones that can match
 | 
			
		||||
          exactly, and ones that cannot.  For example, `.a.b.c` is an
 | 
			
		||||
          exact match path expression, while `.a[].b` is not.
 | 
			
		||||
 | 
			
		||||
          `path(exact_path_expression)` will produce the array
 | 
			
		||||
          representation of the path expression even if it does not
 | 
			
		||||
          exist in `.`, if `.` is `null` or an array or an object.
 | 
			
		||||
 | 
			
		||||
          `path(pattern)` will produce array representations of the
 | 
			
		||||
          paths matching `pattern` if the paths exist in `.`.
 | 
			
		||||
 | 
			
		||||
        examples:
 | 
			
		||||
          - program: 'path(.a[0].b)'
 | 
			
		||||
            input: 'null'
 | 
			
		||||
            output: ['["a",0,"b"]']
 | 
			
		||||
          - program: '[path(..)]'
 | 
			
		||||
            input: '{"a":[{"b":1}]}'
 | 
			
		||||
            output: ['[[],["a"],["a",0],["a",0,"b"]]']
 | 
			
		||||
 | 
			
		||||
      - title: "`del(path_expression)`"
 | 
			
		||||
        body: |
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user