[exim] a couple more problems with parsing JSON

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Victor Ustugov
Datum:  
To: exim-users
Betreff: [exim] a couple more problems with parsing JSON
Hello

Some web servers provide useful information that I cannot use.


# exim -be '${sg{${readsocket{inet:ipinfo.io:443}{GET /91.202.74.134
HTTP/1.1\r\nHost: ipinfo.io\r\nConnection:
close\r\n\r\n}{20s:tls=yes:sni=ipinfo.io}{\n}{socket
failure}}}{\N^((.+)\r?\n)+\r?\n\N}{}}'
{
"ip": "91.202.74.134",
"hostname": "mx.org.ua",
"city": "Kyiv",
"region": "Kyiv City",
"country": "UA",
"loc": "50.4547,30.5238",
"org": "AS44600 \"GIGATRANS UKRAINE\", LLC",
"postal": "03027",
"timezone": "Europe/Kyiv",
"readme": "https://ipinfo.io/missingauth"
}

I ran into problems parsing such JSON because it contains commas.

Here is a simpler example:


without comma:
# exim -be '${extract jsons{opt2}{ \{ "opt1":"1","opt2":"2 3" \}}}'
2 3

with comma
# exim -be '${extract jsons{opt2}{ \{ "opt1":"1","opt2":"2,3" \}}}'
Failed: missing '"' wrapping string result for extract jsons


There is another issue with double quotes and ${extract jsons{.


extract json:
# exim -be '${extract json{opt2}{ \{ "opt1":"1","opt2":"2 \"3\"" \}}}'
"2 "3""


This is correct result but I have to remove the double quotes myself.

If I use ${extract jsons{ instead of ${extract jsons, then I should get
the result without the double quotes around the text value.

But instead I get the part of the value before the first escaped double
quote:


# exim -be '${extract jsons{opt2}{ \{ "opt1":"1","opt2":"2 \"3\"" \}}}'
2


I expected to get this result:
2 "3"


I use exim 4.95 from FreeBSD ports tree.

I tried exim 4.96 and got the same results.


--
Best wishes Victor Ustugov
mailto:victor@corvax.kiev.ua
public GnuPG/PGP key: https://victor.corvax.kiev.ua/corvax.asc

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/