mirror of
				https://github.com/stedolan/jq.git
				synced 2024-05-11 05:55:39 +00:00 
			
		
		
		
	To import a module now use:
    # Import module.jq file:
    import "relative/path/to/module" as foo;
    # Use the module's defs as foo::<def-name>
To import a JSON file:
    # Read file.json:
    import "relative/path/to/file" as $foo;
    #
    # Use as $foo::foo
Using `-L` now drops the builtin library path and appends the requested
path to the empty array (or the result of an earlier `-L`).
Support for the `$JQ_LIBRARY_PATH` environment variable has been
removed.
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			689 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			689 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
module {whatever:null};
 | 
						|
import "a" as foo;
 | 
						|
import "d" as d {search:"./"};
 | 
						|
import "d" as d2{search:"./"};
 | 
						|
import "e" as e {search:"./../lib/jq"};
 | 
						|
import "f" as f {search:"./../lib/jq"};
 | 
						|
import "data" as $d;
 | 
						|
def a: 0;
 | 
						|
def c:
 | 
						|
  if $d::d[0] != {this:"is a test",that:"is too"} then error("data import is busted")
 | 
						|
  elif d2::meh != d::meh then error("import twice doesn't work")
 | 
						|
  elif foo::a != "a" then error("foo::a didn't work as expected")
 | 
						|
  elif d::meh != "meh" then error("d::meh didn't work as expected")
 | 
						|
  elif e::bah != "bah" then error("e::bah didn't work as expected")
 | 
						|
  elif f::f != "f is here" then error("f::f didn't work as expected")
 | 
						|
  else foo::a + "c" + d::meh + e::bah end;
 |