@vitaliy_balahnin
Новичок в веб-разработке

Go пакеты для комфортной работы с json Есть?

Есть ли удобные инструменты для работы с json где много уровней вложенности?
Создавать правильную структуру под json пока не получаются. Как по простому добраться до нужных элементов?
Пример json:
{"lastUpdated":1565629,"snapshot":{"status":"SUCCESS","gameId":18014398527319110,"gameMode":"ConquestLarge","mapVariant":0,"currentMap":"Levels/MP/MP_Prison/MP_Prison","maxPlayers":64,"waitingPlayers":0,"roundTime":1506,"defaultRoundTimeMultiplier":300,"conquest":{"2":{"tickets":1842,"ticketsMax":2400},"1":{"tickets":2137,"ticketsMax":2400}},"teamInfo":{"0":{"faction":0,"players":{"1560173815":{"name":"TerminaRambor","tag":"","rank":87,"score":0,"kills":0,"deaths":0,"squad":0,"role":1},"1109763858":{"name":"Dusk22RUS","tag":"","rank":140,"score":0,"kills":0,"deaths":0,"squad":0,"role":1},"1797970753":{"name":"reyreene","tag":"","rank":31,"score":0,"kills":0,"deaths":0,"squad":0,"role":1},"1886958542":{"name":"this-fiasco-bro","tag":"","rank":27,"score":0,"kills":0,"deaths":0,"squad":0,"role":1}}},"1":{"faction":0,"players":{"1110980157":{"name":"Piotreq69","tag":"","rank":23,"score":10092,"kills":8,"deaths":16,"squad":4,"role":1},"325391494":{"name":"student_ivan","tag":"","rank":112,"score":4522,"kills":18,"deaths":15,"squad":4,"role":1},"409478800":{"name":"Daemon-car","tag":"","rank":112,"score":6924,"kills":14,"deaths":7,"squad":4,"role":1},"1329555183":{"name":"_RAINMAN_Channel","tag":"","rank":56,"score":3757,"kills":7,"deaths":8,"squad":4,"role":1},"1938003978":{"name":"LilBleater","tag":"","rank":83,"score":6905,"kills":29,"deaths":4,"squad":1,"role":1},"855996716":{"name":"keeshoek85","tag":"","rank":66,"score":3950,"kills":9,"deaths":10,"squad":1,"role":1},"1947697433":{"name":"baGStube_Nico","tag":"","rank":7,"score":869,"kills":4,"deaths":7,"squad":2,"role":1},"1120640087":{"name":"revoltekDaniel","tag":"","rank":50,"score":872,"kills":2,"deaths":7,"squad":2,"role":1},"1743990185":{"name":"El_Axou","tag":"","rank":72,"score":2188,"kills":6,"deaths":5,"squad":2,"role":1},"1004850326175":{"name":"AmitaNancy","tag":"IFL","rank":118,"score":2010,"kills":10,"deaths":6,"squad":2,"role":1},"1003720320305":{"name":"PumaTS","tag":"","rank":18,"score":575,"kills":0,"deaths":2,"squad":1,"role":1},"1740515214":{"name":"Moss_1010_IQ","tag":"","rank":129,"score":565,"kills":3,"deaths":2,"squad":3,"role":1},"1003722544016":{"name":"S3L3T","tag":"","rank":23,"score":469,"kills":2,"deaths":1,"squad":3,"role":1},"1024175845":{"name":"iwann45","tag":"","rank":140,"score":496,"kills":3,"deaths":2,"squad":3,"role":1},"1133117673":{"name":"sedoy699","tag":"poof","rank":61,"score":45,"kills":0,"deaths":0,"squad":1,"role":1},"1004449073633":{"name":"ArknightExcusiai","tag":"","rank":41,"score":110,"kills":1,"deaths":1,"squad":5,"role":1}}},"2":{"faction":1,"players":{"1828726694":{"name":"Buzdovan4","tag":"","rank":119,"score":6166,"kills":20,"deaths":13,"squad":1,"role":1},"1824699528":{"name":"BongoWongo8","tag":"","rank":69,"score":2460,"kills":1,"deaths":8,"squad":1,"role":1},"389209916":{"name":"karvanoppa1","tag":"","rank":18,"score":4127,"kills":10,"deaths":11,"squad":4,"role":1},"934042081":{"name":"Afarys","tag":"","rank":69,"score":3635,"kills":9,"deaths":7,"squad":4,"role":1},"1781462740":{"name":"L_Limonchik_L","tag":"","rank":110,"score":1542,"kills":4,"deaths":7,"squad":4,"role":1},"387994498":{"name":"PirajOK13","tag":"","rank":65,"score":4630,"kills":9,"deaths":10,"squad":1,"role":1},"1092777159":{"name":"TheGolderSkuller","tag":"","rank":81,"score":5721,"kills":20,"deaths":16,"squad":1,"role":1},"383764521":{"name":"Kirikou97212","tag":"VIVA","rank":140,"score":4525,"kills":8,"deaths":13,"squad":4,"role":1},"1695604914":{"name":"tonirankasee","tag":"","rank":6,"score":2969,"kills":15,"deaths":10,"squad":2,"role":1},"1782407767":{"name":"TonTon_Omen","tag":"FR","rank":34,"score":1423,"kills":6,"deaths":7,"squad":1,"role":1},"1772633522":{"name":"35jagermeister35","tag":"","rank":51,"score":4500,"kills":21,"deaths":3,"squad":4,"role":1},"875251423":{"name":"icanon_mac","tag":"","rank":34,"score":775,"kills":4,"deaths":2,"squad":2,"role":1},"1095933769":{"name":"hider233","tag":"","rank":58,"score":1174,"kills":8,"deaths":5,"squad":3,"role":1},"1003783606266":{"name":"Agvanich","tag":"","rank":24,"score":239,"kills":1,"deaths":1,"squad":3,"role":1},"1003707849241":{"name":"klaskeladden123","tag":"","rank":34,"score":179,"kills":1,"deaths":2,"squad":3,"role":1}}}}}}


Нужен числовой ключ каждого юзера Как пример 1003783606266 и всё что внутри name, rank,... для записи в более однотипный json.
  • Вопрос задан
  • 104 просмотра
Решения вопроса 1
@falconandy
В некоторых случаях удобно использовать
для чтения https://github.com/tidwall/gjson
для записи https://github.com/tidwall/sjson
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы