JSON value parse with Python -


I have such type of JSON bits and I need to use only datetime fields instead of the first integer entry But I am not getting any way to do this which is using Python. Any ideas? "," "Number": 123, "values": [["95", "2011-12 - 4"], [" 90 "," 2011-10-03 "]]

You assume in a loop Can open:

  Import json data = json.loads _ (_ _ _ _ _ _ _ =), date in data ['value']: # 'date' Do something with>  

I have assigned the first value to code in each nested list, which traditionally tells the code reader that you are ignoring that value.

If you want to do something useful with the date, you may want to parse it:

  import json import datetime data = json.loads (your_json_value) _ For data, date in ['value']: date =) datetime.datetime.strptime (date, '% Y-% m-% d'). Date ()  

Demo:

  & gt; & Gt; & Gt; Import json & gt; & Gt; & Gt; Import Date Time & gt; & Gt; & Gt; Your_json_value = '' '... ... ... ... "Boolean": True, ... "Null": blank, ... "number": 123, ... "value": [ .... .. "95", ... "2011-12-04" ......... ... [... "90", ... "2011-10-03" ...] ...] ...} ... '' '& gt; & Gt; & Gt; For _, date [data ']': ... date = datetime.datetime.strptime (date, '% Y-% m-% d'). Date () ... Print ('{:% a% D% B% Y}' format (date)) ... Sun 04 Dec 2011 Mon 03 Oct 2011  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -