Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jqlang/jq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 57026b65dad78370547a5d2f569f8e91a5287c80
Choose a base ref
..
head repository: jqlang/jq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b4bf2ceb2958eb9aac54cdf949af27d6ae1e5c3c
Choose a head ref
Showing with 15 additions and 2 deletions.
  1. +1 −0 src/jv_aux.c
  2. +2 −2 src/jv_parse.c
  3. +12 −0 tests/jq.test
1 change: 1 addition & 0 deletions src/jv_aux.c
Original file line number Diff line number Diff line change
@@ -215,6 +215,7 @@ jv jv_has(jv t, jv k) {
} else if (jv_get_kind(t) == JV_KIND_ARRAY &&
jv_get_kind(k) == JV_KIND_NUMBER) {
if (jvp_number_is_nan(k)) {
jv_free(t);
ret = jv_false();
} else {
jv elem = jv_array_get(t, (int)jv_number_value(k));
4 changes: 2 additions & 2 deletions src/jv_parse.c
Original file line number Diff line number Diff line change
@@ -491,9 +491,9 @@ static pfunc check_literal(struct jv_parser* p) {
case 't': pattern = "true"; plen = 4; v = jv_true(); break;
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
case 'n':
/* if it starts with 'n', it could be a literal "nan" */
// if it starts with 'n', it could be a literal "nan"
if (p->tokenpos != 3) {
pattern = "null"; plen = 4; v = jv_null(); break;
pattern = "null"; plen = 4; v = jv_null();
}
}
if (pattern) {
12 changes: 12 additions & 0 deletions tests/jq.test
Original file line number Diff line number Diff line change
@@ -1799,6 +1799,18 @@ reduce .[] as $then (4 as $else | $else; . as $elif | . + $then * $elif)


# { $__loc__ } works

{ a, $__loc__, c }
{"a":[1,2,3],"b":"foo","c":{"hi":"hey"}}
{"a":[1,2,3],"__loc__":{"file":"<top-level>","line":1},"c":{"hi":"hey"}}


# nan is parsed as a valid NaN value from JSON

fromjson | isnan
"nan"
true

tojson | fromjson
{"a":nan}
{"a":null}