[SOLVED] Extracting Nested data from JSON files using python

i have never worked with json files in python before … and i need to extract some data from around 1000 json files . can anyone help me?

sample data:

“data”:{
“attributes”:{
“productnumber”:{
“values”:[
{
“source”:“internal”,
“locale”:“en-US”,
“value”:“04019669”
}

i need to extract productnumber value from all these json files and move it to some other file. initially i thought of using regex but that’s not an optimize solution. if anyone of you know something better to extract these information other than python let me know.

can you upload json file

Data is confidential bro… can’t upload it. This is not a personal project.
Moreover you got the point what i am trying to do with jason files

Please read the FAQ, Deep coding questions are not allowed! :slightly_frowning_face:

  • How to code this, can you help me with a coding script? I am stuck with a code, now what to do? <<< Please, avoid asking such deep programming language questions, as there is already a website dedicated for this stackoverflow ! :slightly_frowning_face:

Anyways, You can use regular expressions to isolate those JSON objects you are interested in from your available files. Here is a relevant discussion. & also check the below thread! :slight_smile:

3 Likes

I did not know about it. I’ll remember next time. Thanks (:

1 Like

I am late but… if you will notice the json
data”:{
“attributes”:{
“productnumber” :{
“values”:[
{
“source”:“internal”,
“locale”:“en-US”,
“value”:“04019669”
}

It’s just a dictionary under a dictionary so
You can try something like
Print(Data[“attributes”] )
It will return a dictionary of product number and values key value dictionary.

1 Like