0

Is there an easy way to use glom to get an unknown key from a dictionary?

the ??? represents random data that I am trying to capture from an API

    book = {"???":[{ "globalIdenity":208565940},{"globalIdenity":228049454}]}

    spec = 
    output_data = glom(book, spec)
    print(output_data)
Scott
  • 1

1 Answers1

0

Use an iterator for values then use the next call to get the value

book = {"???":[{ "globalIdenity":208565940},{"globalIdenity":228049454}]}

result = next(iter(book.values()))

print(result)

#output
[{'globalIdenity': 208565940}, {'globalIdenity': 228049454}]
think-maths
  • 917
  • 2
  • 10
  • 28