bawa_91
bawa_91

Reputation: 17

How to do JSON transformation in python?

I have done JSON transformation using this demo website

http://jolt-demo.appspot.com/#inception

I even got the Json spec ready

[
  {
    "operation": "shift",
    "spec": {
      "r_id": "r_id",
      "data": {
        "list": {
          "*": {
            "uid": "uid",
            "item_list": {
              "*": {
                "p_id": "p_id",
                "sku": "sku",
                "q": "q",
                "pr": "pr"
              }
            }
          }
        }
      }
    }
  }
]

I can seem to find a python package to do this, all available packages are in Java, Is there any pythonic way to do this transformation ?

Upvotes: 0

Views: 460

Answers (1)

Leonardo Boscolo
Leonardo Boscolo

Reputation: 467

Python has an apposite standard library to deal with JSON.

Here is how you can transform JSON to Python:

import json
x =  '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)
print(y["name"])
Output
John

Upvotes: 1

Related Questions