I
I
impressive172020-06-08 23:59:35
go
impressive17, 2020-06-08 23:59:35

How to parse JSON array in golang?

I get a very large JSON in resp.body. It has several fields and an array of order objects. The order object also has a lot of fields and, among others, there is an order_id field. I need to parse this JSON by pulling out a list of order_id. How can I do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2020-06-09
@impressive17

The most efficient way would be to use this package:
https://github.com/tidwall/gjson
with the GetMany.

E
Egor Ommonik, 2020-06-09
@Ommonick

There are also generators of structures like https://mholt.github.io/json-to-go/
We push an example of json there and get structures, write them in code and use them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question