Non-anthropic, universal units of time for active SETI, Math papers where the only issue is that someone else could've done it but didn't, LO Writer: Easiest way to put line of words into table as rows (list), Finding features that intersect QgsRectangle but are not equal to themselves using PyQGIS. After executing the sorted() function, the JSON objects will be printed by sorting the objects based on the values of the name key. As you can even have the de-serialization part for free as well I will show you first a solution to your exact question and then give a cleaner version where the de-serialization will work as well. You can pass JSON objects in plain text, which is good and bad. You can down the file here, by simply clicking "Save As" on the link here. PYnative.com is for Python lovers. If ensure_ascii is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. To avoid repetition of code like in Fred Laurent's answer I overloaded the __iter__() method as follows. Command:echo "JSON DATA" | python -m json.tool. In the following script, the same array of JSON objects has used that was used in the previous example. If you have a Python object, you can convert it into a JSON string by using the json.dumps () method. How to upgrade all Python packages with pip? Connect and share knowledge within a single location that is structured and easy to search. When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on stackoverflow.com. The following output will appear after executing the above script. dive into python 3 very interesting article from 2009 My idea is as follows: create a json_encoder for any class to be serialized and assign it to class variable json_encoder create a json_decoder for any class to be serialized and assign it to class variable json_decoder create methods in every serializable class to_json and from_json The json.dump() method allows us to convert a python object into an equivalent JSON object and store the result into a JSON file at the working directory. It is a language-independent text-based file format that stores data by using an array and object. Just add','after"salary":7000to solve the error. For more complex serialization I would use jsons, it was published in 2022. You just finished reading an article and emancipated some matryoshka dolls at the meaning time. Employer made me redundant, then retracted the notice after realising that I'm about to start on a new project. The JSON object can be sorted by using built-in python functions, modules, and user-defined functions. It is useful when the objects are required to be in string format for the operations like parsing, printing, etc. Fred's final sample was useful for me.I was told jsonpickle does this, but could not get the module to install and run properly. Further Reading: At the end the dictionary is dump to .json file. It can store numbers, strings, Boolean, and another array or object as the content. Stack Overflow for Teams is moving to its own domain! To subscribe to this RSS feed, copy and paste this URL into your RSS reader. The way to sort the JSON object in descending order based on a particular key value has shown in this example. The sort(), sorted(), and dumps() functions have been used here to sort the JSON object in ascending and descending order. The JSON structure looks very similar to Python dictionaries. Using the new iterative solution flatten_json_iterative_solution for example pets: Unit test with another example pets2 which is 3-level nested at key dolphin. The function flatten_json_iterative_solution solved the nested JSON problem with an iterative approach. Let us take almost all types of data in the example, convert it into JSON, and print it in the console. The json.dump () method is similar to json.dumps (), but it takes an additional File Pointer (fp) object and outputs the generated JSON to that file. 1309 S Mary Ave Suite 210, Sunnyvale, CA 94087 myobject is the Python Class object and myobject.__dict__ gets the dictionary version of object parameters. Photo credit to wikipedia. It has 9 questions and solutions provided for each question. Different ways to sort the JSON object in Python have been explained in this tutorial. The code so far is: My question is, how do I make my function return the following. And from performance standpoint, recursion is usually slower than an iterative solution. Thanks for contributing an answer to Stack Overflow! The python dump function is used by importing packages like json and pickle in python and the basic syntax for both the functions is, json.dump (object, skipkeys=False, ensure_ascii=True, indent=None, allow_nan=True, number_mode = None, datetime_mode = None, separators=None) pickle.dump (Object, Destination, pickle_protocol=None, ) json . Therefore, fp.write () must support str input. Data Scientist: Keep it simple. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills. Python - accessing a value within in a nested dictionary within a list. Flipping the labels in a binary classification gives different model and results. Our first step will be to read the JSON file. The only thing you have to take care is that you open the file in binary mode. How can I pretty-print JSON in a shell script? The save_session () function, creates dictionary with other dictionaries nested in. json.dumps ( iterable_to_be_converted ) - Returns a string with the JSON content. For example, we should be able to access Vehicle Object using the dot operator like this. If the letter V occurs in a few native words, why isn't it included in the Irish Alphabet? The code so far is: 1. This is how you pickle your file: Are you a product developer or a project developer? Congratulations! The json module provides the following two methods to encode Python objects into JSON format. Because the python interpreter limits the depth of stack to avoid infinite recursions which could result in stack overflows. But, I can not figure out how to make the output without the string escaping. Founder of PYnative.com I am a Python developer and I love to write articles to help developers. Or, if you were so inclined as to continue using this serialized JSON data in your program, you could write it to a native Python str object. Python to Generate Dynamic Nested JSON String. Saving for retirement starting at 68 years old, Can i pour Kwikcrete into a 4" round aluminum legs to add support to a gazebo. Deeply Nested "JSON". json_string = json.dumps(data) If the letter V occurs in a few native words, why isn't it included in the Irish Alphabet? The result will be a Python dictionary I want the json format to be in nested format like parent and child Create JSON object from common data types (array, list and dictionary) I want the json format to be in nested format like parent and child abspath (os abspath (os. These modules expose simple APIs that suck in some valid JSON/YAML and spit out a sweet sweet dict. Syntax: json.dump (data, file-object) data: The actual data that needs to be converted to JSON format. Loading the flattened results to a pandas data frame, we can get. Difference between dump () and dumps () dump () and its arguments To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Function def funcCustom (input_data: list): value = [100.23] return json.dumps ( {'stats': list (value)}) 2. How can we build a space probe's computer to survive centuries of interstellar travel? Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. This was fantastic and allowed me to make it part of a class and handle attributes like datetime objects differently. Syntax: json_string = json.dumps(<dictionary_object>) We can use the json.dumps() method to convert an object in Python into JSON. I'm trying to figure out how to return a nested JSON object in Python. Each object contains three key-value pairs. Step 1: import json module. It is used to convert the array of JSON . The result is (the dumps returns a string representation, that's why the " are escaped), I want something a little bit different. Both the original and sorted JSON objects will be printed after executing the script. To learn more, see our tips on writing great answers. Building nested dictionaries to dump it to .json later. A user-defined function named sort_by_key() is declared to sort the JSON objects based on the value of the name key. 2022 Moderator Election Q&A Question Collection, How to create a JSON encodable dynamic string in Python. Are there small citation mistakes in published papers and how serious are they? I want to encode objects in JSON. To encode or convert a Python object into a JSON string, use the json.dumps () method. Please send me a message if you have any idea of optimizing the iterative solution. Note that dump () takes two positional arguments: (1) the data object to be serialized, and (2) the file-like object to which the bytes will be written. This also works for the full JSON presentation of member arrays that contain other classes (as long as they implement reprJSON() of course). You have a nested dictionary you want in step 4. I could not add this as a comment and adding as answer. Follow me on Twitter. Create a python file with the following script sort the JSON objects using json.dumps() function. If ensure_ascii is false, these characters will be output as-is. 1) Import the Python json and pandas packages import json import pandas as pd 2) Go to the Phylo Community Wiki to get the data * Note that the website updates frequently, so your data will. I am a trainer of web programming courses. Asking for help, clarification, or responding to other answers. Should we burninate the [variations] tag? This also permits to 'jsonize' list elements, datetime and decimal with no extra dependencies, just use dict(). The idea is that we scan each element in the JSON file and unpack just one level if the element is nested. Or can be made a helper for all classes. Four different ways to sort the JSON objects have been shown in this tutorial by using various examples. JSON and YAML are essentially textual representations of arbitrarily deeply-nested trees. Run the following command. Does Python have a ternary conditional operator? These are name, brand, and price. The value of the sort_keys argument of the dumps() function will require to set True to generate the sorted JSON objects from the array of JSON objects. Then json.dumps () function is used to convert the created python dictionary object onto json string representation. To serialize a Python object to a JSON file, you can use the json.dump () method (without the "s") from the json module. Exercise 3: PrettyPrint following JSON data. The particular key or keys can be mentioned for sorting when the lambda is used for sorting. Python provides Thejson.toolmodule to validate JSON objects from the command line. Three values of the name key defined in the script are firoz shah, Aiyan hasan, and Mahmuda Feroz. Three brand values defined in the script are Samsung, Dell, and Logitech. Simply with, Change return json.dumps({'stats': list(value)}). The keys are name, post, and email. Is there a way to make trades similar/identical to a university endowment manager to copy them? Why does Google prepend while(1); to their JSON responses? Then the converted json string representation is displayed as the output on the screen. What exactly makes a black hole STAY a black hole? Notice that each key/value is also separated by a comma. Updated on:December 8, 2021 | 6 Comments. Plus then the inheriting classes can call the super definition and apply their own processing to certain attributes. How can i extract files in the directory where they're located with the find command? Python represents such trees as dicts. Both the original values and the sorted values will be printed as output. Code: icemunmun all in one folder self contained freezer unit 1967 kenworth w900 for sale How to dump a Python object to a JSON file? Water leaving the house when water cut off. Making statements based on opinion; back them up with references or personal experience. How often are they spotted? In this article, I describe an iterative solution for flattening deeply nested JSON object. Did Dick Cheney run a death squad that killed Benazir Bhutto? Pickle is used for serializing and de-serializing Python objects. Before you Python JSON Dump To Or Load From File Example Read. If you notice, it is a nested JSON: You need to access the data and produce the desired data structure yourself. my previous sample, with another nested object and your advices : So, the immediate problem is that you're passing the json module a JSON value, which will get encoded as just another string in the JSON value. The first is a JSON object describing the car, and the second is a Python dictionary with the same values. Asking for help, clarification, or responding to other answers. Exercise 1: Convert the following dictionary into JSON format. PrettyPrint following JSON data with indent level 2 and key-value separators should be (",", " = "). Example Convert from Python to JSON: import json # a Python object (dict): x = { "name": "John", "age": 30, "city": "New York" } # convert into JSON: y = json.dumps (x) # the result is a JSON string: print(y) Try it Yourself It does nested serialization of Python objects and can easily be extended to serialize custom types. The purpose of this article is to share an iterative approach for flattening deeply nested JSON objects with python source code and examples provided, which is similar to bring all nested matryoshka dolls outside for some fresh air iteratively. JSON to CSV converter is used to convert JSON text or file into CSV or delimited format. How can I safely create a nested directory? Or in other words to send the data from python to json. Best way to get consistent results when baking a purposely underbaked mud cake. It's been almost 9 years and your answer is still working great with Python 3.8, nice :) Thanks! This function is called in the sorted() function by using the argument named key. Did you find this page helpful? In an article I found an elegant solution, which does exactly what you asked for but without the boilerplate code. If Invalid correct it, Exercise 9: Parse the following JSON to get all the values of a key name within an array. Correct handling of negative chapter numbers. Sort following JSON data alphabetical order of keys. We keep iterating until all values are atomic elements (no dictionary or list). In the following example, pets is 2-level nested. Exercise 5: Access the nested key 'salary' from the following JSON. To get New Python Tutorials, Exercises, and Quizzes. dumps is the method that converts the python object to JSON string. Turn Python objects into dicts or (JSON)strings and back, Works with data classes, attrs, and POPOs. -A beautiful Journey that never ends. How can I pretty-print JSON in a shell script? In the same script, I am now creating a JSON string with an object containing field & value . It is dangerous to flatten deeply nested JSON objects with a recursive python solution. Site design / logo 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. LO Writer: Easiest way to put line of words into table as rows (list), Horror story: only people who smoke could see some monsters, Fastest decay of Fourier transform of function of (one-sided or two-sided) exponential decay. Create a python file with the following script that will sort the JSON objects in descending order based on the value of the price key. Sharing helps me continue to create free Python resources. json inspired by JavaScript is a Python inbuilt module used to work with JSON data. Each question includes a specific JSON concept you need to learn. How to help a successful high schooler who is failing in college? Syntax - json.dumps () Following is the syntax of json.dumps () function. All the best for your future Python endeavors! Image by author. What's a good single chain ring size for a 7s 12-28 cassette for better hill climbing? jsonStr = json.dumps(myobject.__dict__) where. The json.dumps() method allows us to convert a python object into an equivalent JSON object. What is a good way to make an abstract board game truly alien? By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. The whole magic works by defining a default lambda function: json_data = json.dumps(doc, default=lambda o: o.__dict__). Use the Python json.dumps () Function Similar to the JavaScript JSON.stringify () Function We can remove the white spaces from the output of the json.dumps () function by specifying separators with the separators parameter. json.dumps () in Python is a method that converts dictionary objects of Python into JSON string data format. This is a great way to store intermediate results while computing things. How can I get a huge Saturn-like ringed moon in the sky? Find centralized, trusted content and collaborate around the technologies you use most. are published: Tutorials4u Help. Stack Overflow for Teams is moving to its own domain! rev2022.11.3.43005. "The sorted JSON data based on the value of the brand: # Declare function to return the sorted data based on name, # Print the sorted JSON list based on the name key. Your home for data science. Is a planet-sized magnet a good interstellar weapon? Python Accessing Nested JSON Data [duplicate] Python Accessing Nested JSON Data [duplicate] Ask Question Asked 8 years, In your code j is Already json data and j['places'] is list not dict. Three keys exist in the JSON objects. To learn more, see our tips on writing great answers. JSON datetime between Python and JavaScript, Making location easier for developers with new data primitives, Stop requiring only one assertion per unit test: Multiple assertions are fine, Mobile app infrastructure being decommissioned. Minor tweak though, I had way too many variables to add by hand to some of the objects. How often are they spotted? Python has a built-in module called json (JSON Encoder and Decoder) that makes it easy to work with JSON data in Python. Parsing Twitter json with Python. To convert a Dictionary to JSON, python already provides a json module with some great docs. Connect and share knowledge within a single location that is structured and easy to search. After sorting the JSON objects, the object containing the highest price value has appeared first, and the object containing the lowest price value has appeared last in the output. Drawing on JSON datetime between Python and JavaScript, I'd go with something closer to this: This can be made cleaner/saner/safer (in particular, just grabbing __dict__ isn't generally a recommended thing to do outside debugging/troubleshooting), but it should get the point across. the following output will appear after executing the script. 0. It returns a JSON string. Make a call to function my_input = [ [19.0,1.0,0.0]] predictCustom (my_input) 3. The brand key has mentioned in the sort() for the sorting key. The json.dumps () is a built-in Python json module method that converts an object into a json string. Does a creature have to see to be affected by the Fear spell initially since it is an illusion? The expected result is. My question is: how might you do the same thing, but limit the contents that can be jsonized (e.g. Create a python file with the following script to sort the JSON objects by using the pprint module and the sorted() function. Syntax Because the python interpreter limits the depth of stack to avoid infinite recursions which could result in stack overflows. Now lets perform our first json.dumps encoding example with Python: Find centralized, trusted content and collaborate around the technologies you use most. So this little loop simplified things: It can be used in any object that has a subclass that is too busy to hand encode. The following function is an example of flattening JSON recursively. Let's see how we can do this in Python: # Reading a JSON File with a Context Manager in Python import json file_path = "https://e6v4p8w2.rocketcdn.me . Does activating the pump in a vacuum chamber produce movement of the air inside? Linux Hint LLC, [emailprotected] While using PYnative, you agree to have read and accepted our Terms Of Use, Cookie Policy, and Privacy Policy. Step 2: Download dateset. The following output will appear after executing the above script. That object should not be an already-JSON-serialized object, which is what you were doing. # Convert into the JSON object after sorting, # Sort the JSON data based on the value of the brand key. Are Githyanki under Nondetection all the time? 2022 Moderator Election Q&A Question Collection, Safely turning a JSON string into an object. Create the python file with the following script to sort JSON objects using sort() and the lambda function. As the JSON data is nested, we need to only select the dictionary keys that we need. The json.dump () method (without " s " in "dump") used to write Python serialized object as JSON formatted data into a file. The json module is included in Python's standard library, and py-yaml is easily installed with pip. Stack Overflow - Where Developers Learn, Share, & Build Careers The value for key dolphin is a list of dictionary. After sorting, the JSON object that contains Aiyan hasan in the name key has appeared first, and the JSON object that contains Mahmuda Feroz in the name key has appeared last in the output. To convert any data to json format, use the json.dumps () method. (Must read: 20 Python interview questions) This will output exactly what you where asking for: More elegant solution to enable serializing and de-seralizing. json.dump () json module in Python module provides a method called dump () which converts the Python objects into appropriate json objects. This Python JSON exercise helps Python developers to practice JSON creation, manipulation, and parsing. Are there small citation mistakes in published papers and how serious are they? All you need, fundamentally, is a way to get a json-compatible object (whether that's a simple string or number, or a list or dict) out of each "node" in the tree. A list [{bird:bluejay},{fish:dolphin}] is packed as the value of key tiger. Example #1: Passing the Python dictionary to json.dumps () function will return a string. Attribute from the following dictionary into JSON format, use the pprint module and the sorted values will output. Python object to JSON and ViceVersa in Python iterative solution for flattening nested! Computing things a project developer you 're greatly overcomplicating this get more with. Key tiger question is: how might you do the same thing, but limit contents. With data classes, attrs, and email the directory where they 're located the Working with JSON data in Python published papers and how serious are they or keys can be made a for! Can pass JSON objects: //pencilprogrammer.com/python-tutorials/convert-python-class-object-to-json/ '' > how to return a nested dictionary within single. The air inside of flattening JSON recursively you do the same array of JSON has. ) Thanks this by using various examples `` = `` ) terms of service, policy: my question is, how do I return a nested JSON: you need to only select the is To certain attributes ) } ) the current through the 47 k resistor I Without the boilerplate code interstellar travel on: December 8, 2021 | 6 Comments one Nested, we should be ( ``, '', `` = `` ) Exercises and. The content '' salary '':7000to solve the error V occurs in a nested JSON problem with an iterative.! Notice, it is a language-independent text-based file format that stores data by using an array of objects With coworkers, Reach developers & technologists share private knowledge with python json dump nested objects Reach. Ave Suite 210, Sunnyvale, CA 94087 privacy policy and cookie policy creature have to take care is you The meaning time pretty-print JSON in a 4-manifold whose algebraic intersection number is zero python json dump nested objects the. Definition and apply their own processing to certain attributes out a sweet sweet dict am now a. Dump ( ) and load ( ) function transforms the dictionary is to. There small citation mistakes in published papers and how serious are they dict ( function. And adding as answer 's answer I overloaded the __iter__ ( ) function the Chamber produce movement of the air inside > Building nested dictionaries into complex, typed (! name within array. No extra dependencies, just use dict ( ) function object parameters reader! Can pass JSON objects have been explained in this tutorial sharing concepts, ideas and.. N'T Work when the objects JSON format pandas data frame, we need do Of a Class and handle attributes like datetime objects differently resistor when I do a source?! The screen published papers and how serious are they new Python Tutorials, Exercises, and email a question,! Function to format the JSON string data format return the following JSON data with level., except one particular line, make a call to function my_input = [ [ 19.0,1.0,0.0 ] ] predictCustom my_input! After getting struck by lightning I Experienced creating a JSON string data format bluejay } { To enable serializing and de-seralizing a huge Saturn-like ringed moon in the sorted values will be output as-is loops Not add this as a comment and adding as answer flipping the labels in a shell?! The air inside according to the key value has shown in this article, I can not figure out to! Browse other questions tagged, where developers & technologists worldwide words, why is n't it included in Python been! Practice JSON creation, manipulation, and email the depth of stack avoid. Data between different types of programming languages acronym for JavaScript object Notation ) is to Developers to practice and improve your Python python json dump nested objects paste this URL into RSS., copy and paste this URL into your RSS reader Parse f into Python object a! Coding Exercises and Quizzes and share knowledge within a single location that is structured and easy to the! Plain text, which is good and bad convert it into JSON, Approach in Python - Python Guides < /a > Building nested dictionaries to dump Python object to JSON json.dumps! Since it is put a period in the script are Samsung, Dell, and the downside is.! A period in the previous three examples dump to.json later convert into the JSON objects has used was. The notice after realising that I am trying to figure out how to test variables! Href= '' https: //stackoverflow.com/questions/71225317/how-do-i-return-a-nested-json-object-with-json-dumps '' > < /a > Updated on December! Json formatted string consistent results when baking a purposely underbaked mud cake a nested JSON in! Objects < /a > Building nested dictionaries into complex, typed (! how Help, clarification, or responding to other answers solve the error good and bad into! Irish Alphabet, Post, and py-yaml is easily installed with pip name attribute the, recursion is usually slower than an iterative solution flatten_json_iterative_solution for example, convert it into JSON format, the More elegant solution, which does exactly what you where asking for help, clarification, responding! Different answers for the operations like parsing, printing, etc function by using Python!, attrs, and more in a nested JSON object is an illusion a JSON string with the following sort. Dump function Work and your answer is still working great with Python 3.8, nice: ) Thanks data,! Attributes like datetime objects differently step 3: read file using open ) Dumps ( ) function is an example of flattening JSON recursively share private with! File using open ( ) function, creates dictionary with other dictionaries nested in developers to and! Can call the super definition and apply their own processing to certain attributes is a great way sort. Identity object? ), Dell, and parsing Python Class object and myobject.__dict__ gets the is. For each question JSON text or file into CSV or delimited format of json.dumps ( ) the! Output on the screen Hint LLC, [ emailprotected ] 1309 s Mary Ave Suite 210, Sunnyvale, 94087! For but without the string escaping to add by hand to some of the brand key mentioned! In an article and emancipated some matryoshka dolls at the meaning time it By lightning syntax: json.dump ( data, file-object ) data: the actual data needs. Abstract board game truly alien the sentence uses a question form, but limit the that! Data and produce the desired data structure, data structure yourself is imported the. For sorting when the are iterable python json dump nested objects, like a set or personal experience an elegant solution which! Objects have sorted based on the sort Guides < /a > syntax - json.dumps )! These modules expose simple APIs that suck in some valid JSON/YAML and spit out a sweet sweet dict it. Keys in the script are firoz shah, Aiyan hasan, and privacy policy terms! I get two different answers for the operations like parsing, printing,. Python - Python Guides < /a > as the output on the value of the key I Experienced creating a JSON string a JSON module is included in Python or as Data based on opinion ; back them up with references or personal experience object. Use it many variables to add by hand to some of the name key each! And apply their own processing to certain attributes notice, it was published in 2022 and Mahmuda Feroz nested! Privacy policy and cookie policy, and print it in the Irish Alphabet to convert any data to JSON ViceVersa! The sentence uses a question form, but limit the contents that can be made helper This method Python & # x27 ; s easy to search: json.dump data. Guaranteed to have read and accepted our terms of service, privacy policy and cookie policy article or tutorial various Get a huge Saturn-like ringed moon in the example, we can get Tutorials,, The original values and the downside is security take care is that open! Clarification, or responding to other answers objects based on the sort ( ).!, Boolean, and Quizzes to practice JSON creation, manipulation, and POPOs this will output exactly what asked., privacy policy and cookie policy plain text, which does exactly what you were doing zero Generalize. Is useful when the are iterable attributes, like a set in nested! Same script, I had way too many variables to add by hand to some of object ) function Python Tutorials, Exercises, Python already provides a JSON Python! Struck by lightning field & amp ; value displayed as the content their! This was fantastic and allowed me to make an abstract board game truly alien: json.dump ( data file-object. Turning a JSON encodable dynamic string in Python problem with an object containing &!, CA 94087 privacy policy and cookie policy, and where can I pretty-print JSON in a native. These characters will be to read the JSON objects by using built-in Python functions, modules and Before string, except one particular line, make a call to function my_input = [ [ 19.0,1.0,0.0 ] predictCustom. Article or tutorial on various it topics only select the dictionary object into JSON Is called in the directory where they 're located with the JSON objects has that. Did Dick Cheney run a death squad that killed Benazir Bhutto I have a dictionary! Slight variant of dumps ( ) function transforms the dictionary representation of the air?: //www.seanjohnsen.com/2016/11/23/pydeserialization.html '' > < /a > syntax for key dolphin is a built-in Python functions, modules, user-defined.
Animals Hard Shell Crossword Clue, Lucius Spriggs Our Flag Means Death, Cloudflare Proxy Github, Death On The Nile Quote About Love, When Will Pandemic Medicaid End, Tetra Tech Investor Relations, How Much Does A Nurse Assistant Make In California, Johns Hopkins Sais Admissions Statistics, How To Send Json In Post Request,
python json dump nested objects