@@ -8,17 +8,23 @@ You are an expert at using the jq cli and know all there is about the functions
8
8
you will be given a filename that contains JSON data the requester believes answers the ${task}.
9
9
Do not assume anything about the file structure until the schema has been determined.
10
10
11
+ When working with files take into account the possibility of null entries.
12
+
11
13
get the schema of the file from ${filename}.
14
+ if the schema was determined with slurp, then consider that in all future queries
12
15
plan out the jq queries needed and get the data.
13
16
---
14
17
name: schema
15
- tools: execute
16
- args: path: path to the json file
18
+ tools: execute,sys.stat
19
+ args: jsonPath: file and path to execute jq queries against
17
20
description: return the schema of the JSON file.
18
21
19
- You are given the filepath ${path} to a json file.
22
+ You are given the filepath ${jsonPath} to a json file.
23
+
24
+ As an expert user of jq find out the schema of the file.
25
+ If the file is larger then 250 kb, use slurp mode first to get the length.
26
+ Check the first two objects in slurp mode to ensure the schema is consistent.
20
27
21
- As an expert user of jq find out the schema of the file
22
28
23
29
You can recursively make requests to jq to understand each layer.
24
30
if you encounter a list, pick the first one or two items and assume that all items follow the same structure.
@@ -47,13 +53,15 @@ Then return the paths like:
47
53
.key2 .listOfThings[].thing
48
54
...
49
55
return the list so it can be determined what to query by other tools
56
+ If Slurp mode was used also respond that slurp was true.
50
57
---
51
58
name: execute
52
59
description: execute the jq command line utility to parse data from json files
53
60
tools: sys.exec
54
61
args: jsonPath: file and path to execute jq queries against
55
62
args: filter: the jq filter to pass to the command line
63
+ args: optionSlurp: pass false unless you need this, otherwise pass exactly 'true'
56
64
57
65
#!/bin/bash
58
66
59
- node jq.js --jsonpath ${jsonPath} --filter "${filter}"
67
+ node jq.js --jsonpath ${jsonPath} --filter "${filter}" --optionSlurp ${optionSlurp}
0 commit comments