0

I'm querying elastic search and its returning some json that looks like this:

 {u'count': 1,  u'customer_id': u'AABBCC', u'count': u'20'... .. .. },{}...

What I would like to do convert this kibana response json into a list that only contains a dic or list of customer Ids and their counts so I can use it in some other pythonic task.

Result should look something like

[AABBCC:20, BBCCDD:n, ... ..]

I am currently using

  from elasticsearch import Elasticsearch

In my code. I'm fairly knew to json, open to any suggestion thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
chowpay
  • 1,515
  • 6
  • 22
  • 44
  • 1
    That's not JSON. `u'...'` is Python syntax, not JSON syntax. Perhaps the library you use is deserializing your JSON result into a Python structure before the question is asked? In that case it's not JSON any more, and it has *already* been parsed. – Charles Duffy Jul 19 '18 at 00:21
  • Also in json-format should be double quotes... I think you could simply iterate over the elastic search response and extract your data. – game0ver Jul 19 '18 at 00:23
  • The elastic search response you posted is supposed to be a list of dicts ?? – game0ver Jul 19 '18 at 00:27
  • u there stands for unicode. That is definitely not JSON. You should do a type check. I'm guessing you might get string. – Abhishek Sinha Jul 19 '18 at 00:29
  • Ah ok after reading it more here https://stackoverflow.com/questions/24990706/format-the-output-of-elasticsearch-py I see I need to ask a different question so I will close this out. thanks all – chowpay Jul 19 '18 at 20:25

0 Answers0