Search code examples
pythonjsonsimplejson

Is there a way to remove a json key/value using python and simplejson/json


As the title says I'm looking to strip my json of specific keys, is this possible using json or simplejson with python?


Solution

  • A json will load into a python dict so you can just strip them by dictionary comprehension:

    {k:v for k,v in json.loads(string_where_json_was_readed) if k not in keys_to_strip_list}