sbng / mrt2mmdb

Convert a mrt file into a maxmind database file
1 stars 0 forks source link

Bug: JSON output needs double quotes #3

Closed johnhtodd closed 6 months ago

johnhtodd commented 7 months ago

Lookup.py outputs things with single quotes:

root@dev01:~/mrt/mrt2mmdb/mrt2mmdb# python3 lookup.py --mmdb /etc/vector/maxmind/GeoIP2-City_20231117/GeoIP2-City.mmdb --ipaddress 128.151.224.1
{'city': {'geoname_id': 5112703, 'names': {'en': 'Churchville'}}, 'continent': {'code': 'NA', 'geoname_id': 6255149, 'names': {'de': 'Nordamerika', 'en': 'North America', 'es': 'Norteamérica', 'fr': 'Amérique du Nord', 'ja': '北アメリカ', 'pt-BR': 'América do Norte', 'ru': 'Северная Америка', 'zh-CN': '北美洲'}}, 'country': {'geoname_id': 6252001, 'iso_code': 'US', 'names': {'de': 'Vereinigte Staaten', 'en': 'United States', 'es': 'Estados Unidos', 'fr': 'États Unis', 'ja': 'アメリカ', 'pt-BR': 'EUA', 'ru': 'США', 'zh-CN': '美国'}}, 'location': {'accuracy_radius': 20, 'latitude': 43.078, 'longitude': -77.8375, 'metro_code': 538, 'time_zone': 'America/New_York'}, 'postal': {'code': '14428'}, 'registered_country': {'geoname_id': 6252001, 'iso_code': 'US', 'names': {'de': 'Vereinigte Staaten', 'en': 'United States', 'es': 'Estados Unidos', 'fr': 'États Unis', 'ja': 'アメリカ', 'pt-BR': 'EUA', 'ru': 'США', 'zh-CN': '美国'}}, 'subdivisions': [{'geoname_id': 5128638, 'iso_code': 'NY', 'names': {'de': 'New York', 'en': 'New York', 'es': 'Nueva York', 'fr': 'New York', 'ja': 'ニューヨーク州', 'pt-BR': 'Nova Iorque', 'ru': 'Нью-Йорк', 'zh-CN': '纽约州'}}]}
root@dev01:~/mrt/mrt2mmdb/mrt2mmdb#

These need to be double quotes for jq to parse the JSON correctly, I think.

sbng commented 7 months ago

@johnhtodd Print using json.dumps instead of printing dictionary. fixed. Please review 2477043