The braces, commas and colons, and the quoting of the member name are required;
the spaces are optional.
Matching of the key against the member names is done case-sensitively.
+If a returned value is a JSON string, it retains its leading and
+trailing quotes.
. XXX should be a UTF-8 compare
The results of matching are handled as above.
Field selection and result handling is as above;
there is no choice of field separator.
+If a returned value is a JSON string, it retains its leading and
+trailing quotes.
.wen
/* Pull off the leading array or object element, returning
a copy in an allocated string. Update the list pointer.
-The element may itself be an abject or array.
+The element may itself be an object or array.
+Return NULL when the list is empty.
*/
uschar *
case '}': object_depth--; break;
}
*list = *s ? s+1 : s;
+if (item == s) return NULL;
item = string_copyn(item, s - item);
DEBUG(D_expand) debug_printf_indent(" json ele: '%s'\n", item);
return US item;
}
while (field_number > 0 && (item = json_nextinlist(&list)))
field_number--;
- s = item;
- lookup_value = s;
- while (*s) s++;
- while (--s >= lookup_value && isspace(*s)) *s = '\0';
+ if ((lookup_value = s = item))
+ {
+ while (*s) s++;
+ while (--s >= lookup_value && isspace(*s)) *s = '\0';
+ }
}
else
{
${extract json{IDs}{ \{"id": \{"a":101, "b":102\}, "IDs": \{"1":116, "2":943, "3":234\}\} }}
expect: {"1":116, "2":943, "3":234}
+<${extract json{nonexistent}{ \{"id": \{"a":101, "b":102\}, "IDs": \{"1":116, "2":943, "3":234\}\} }}>
+expect: <>
+
****
# Test "escape" with print_topbitchars
exim -be -DPTBC=print_topbitchars
> {"1":116, "2":943, "3":234}
> expect: {"1":116, "2":943, "3":234}
>
+> <>
+> expect: <>
+>
>
> escape: B7·F2ò
>