Skip to main content

For flattening complex JSONs

Project description

Usage

simple_json_flatten_py is a Python library for flattening complex JSONs

From

{
"a": [ {"b":37},{"c":64}],
"g": 26
}

To

{
  "a_b":37,
  "a_c":64,
  "g":26
}
from simple_flatten_json_py import simple_flatten_json

# Sample JSON data
data={
   "cat":[
      {
         "fish":"tuna"
      },
      {
         "chicken":3
      },
      {
         "medicine":{
            "pills":5
         }
      }
   ]
}
# returns a flattened json 
# {"cat_0_fish": "tuna",  "cat_1_chicken": 3,"cat_2_medicine_pills": 20}

print(simple_flatten_json.flatten_json(data))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_flatten_json-0.0.9.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

simple_flatten_json-0.0.9-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page