inns.xgo 718 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. log := import("log")
  2. cjson := import("cjson")
  3. fmt := import("fmt")
  4. dec := cjson.Decoder("<stdin>")
  5. inn_field_id_map := {
  6. "1305100": true,
  7. "686597": true,
  8. "1300614": true,
  9. "161151": true,
  10. "231711": true,
  11. "1313554": true
  12. }
  13. extract_inns := func(o) {
  14. if !o.custom_fields_values {
  15. return
  16. }
  17. inns := []
  18. for f in o.custom_fields_values {
  19. id := f.field_id
  20. if !id {
  21. continue
  22. }
  23. ok := inn_field_id_map[string(id)]
  24. if !ok {
  25. continue
  26. }
  27. if !f.values || !f.values[0].value {
  28. continue
  29. }
  30. v := f.values[0].value
  31. inns += [v]
  32. }
  33. return inns
  34. }
  35. i := 0
  36. for {
  37. j := dec.decode()
  38. if !j {
  39. break
  40. }
  41. inns := extract_inns(j)
  42. for inn in inns {
  43. i++
  44. log.println(i)
  45. fmt.println(inn)
  46. }
  47. }