daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Sep 19th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. json_obj =
  2.         { "page": [{ "name": "url1", "value": null},
  3.                    { "name": "url3", "value": "3000"},
  4.                    { "name": "url5", "value": "600"},
  5.                    { "name": "url7", "value": null},
  6.                    { "name": "url9", "value": "45"}], "other_value": "others" }
  7.    
  8. for i in json_obj['page']:
  9.     if i['value'] =='null':
  10.         i['value']=None
  11. print(json_obj)
  12. {'other_value': 'others',
  13.   'page': [{'name': 'url1', 'value': None},
  14.   {'name': 'url3', 'value': '3000'},
  15.   {'name': 'url2', 'value': '600'},
  16.   {'name': 'url2', 'value': None},
  17.   {'name': 'url2', 'value': '45'}]}
  18.    
  19. not_null = lambda x: x['value'] != 'null'
  20. old_page = json_obj['page']
  21. json_obj['page'] = list(filter(not_null, old_page))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top