log := import("log") cjson := import("cjson") fmt := import("fmt") dec := cjson.Decoder("") inn_field_id_map := { "1305100": true, "686597": true, "1300614": true, "161151": true, "231711": true, "1313554": true } extract_inns := func(o) { if !o.custom_fields_values { return } inns := [] for f in o.custom_fields_values { id := f.field_id if !id { continue } ok := inn_field_id_map[string(id)] if !ok { continue } if !f.values || !f.values[0].value { continue } v := f.values[0].value inns += [v] } return inns } i := 0 for { j := dec.decode() if !j { break } inns := extract_inns(j) for inn in inns { i++ log.println(i) fmt.println(inn) } }