Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested JSON implemented #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Nested JSON implemented #2

wants to merge 3 commits into from

Conversation

arelangi
Copy link

sample json

[
{
"simulationNum": 15,
"symbol": "EWJ",
"underlyingPrice": 11.085,
"underlyingIV": "0.27545",
"forecastPrice": 10.002890081589,
"forecastIV": "-1.513149252259489",
"forecastDays": "74",
"forecastTime": "20131117",
"forecastAmount": "21177",
"isEliminated": true,
"reasonForElimination": 7,
"results": null,
"responseTime": 0.01491904258728
},
{
"simulationNum": 16,
"symbol": "EZU",
"underlyingPrice": 35.5,
"underlyingIV": "0.469201",
"forecastPrice": 35.773053463701,
"forecastIV": "0.23221417962010502",
"forecastDays": "16",
"forecastTime": "20130920",
"forecastAmount": "2458",
"isEliminated": false,
"reasonForElimination": -1,
"results": {
"profitability": 535.47702780641,
"resultAmount": 2145.2625,
"comissionTotal": 15.2625,
"pathRating": 0.51735265796424,
"results": [
{
"price": null,
"strike": "35",
"time": 1379736000,
"days_to_expiration": "24",
"quantity": -3,
"nodeRating": 0.51735265796424
}
]
},
"responseTime": 4.2060079574585
}
]

@MrZANO
Copy link

MrZANO commented Jun 13, 2018

Hello,
i have a problem

my json is
{ "response": [ { "pos": [ { "position": 1, "page": 1, "directory": "\/colorazione\/laffascinante-effetto-dei-capelli-biondo-scuro\/", "url": "https:\/\/www.example.it\/colorazione\/laffascinante-effetto-dei-capelli-biondo-scuro\/", "visibility": 3, "traffic": 80, "ad_budget": 35.2, "title": "L'affascinante effetto dei capelli biondo scuro", "kd": 33, "traffic_volume": 510, "cpc": 0.44, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] }, { "position": 2, "page": 1, "directory": "\/colorazione\/biondo-scuro-castano-chiaro-bronde\/", "url": "https:\/\/www.example.it\/colorazione\/biondo-scuro-castano-chiaro-bronde\/", "visibility": 1, "traffic": 28, "ad_budget": 12.32, "title": "Biondo scuro, castano chiaro, bronde: quale scegliere?", "kd": 33, "traffic_volume": 510, "cpc": 0.44, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] }, { "position": 3, "page": 1, "directory": "\/colorazione\/capelli-biondo-scuro-a-chi-stanno-bene\/", "url": "https:\/\/www.example.it\/colorazione\/capelli-biondo-scuro-a-chi-stanno-bene\/", "visibility": 1, "traffic": 20, "ad_budget": 8.8, "title": "Capelli biondo scuro a chi stanno bene? - Consigli Beauty example", "kd": 33, "traffic_volume": 510, "cpc": 0.44, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] } ], "keyword": "biondo scuro", "tags": [ "color", "hair color" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 1, "page": 1, "directory": "", "url": "https:\/\/www.example.it\/colorazione", "visibility": 0, "traffic": 0, "ad_budget": 0, "title": "Trova la colorazione che fa per te - Tinte per capelli - example", "kd": 26, "traffic_volume": 20, "cpc": 0.4, "delta_traffic": 0, "trend": { "trend": 1, "abs": 3, "per": 75 }, "tags": [ "hair color" ] } ], "keyword": "tinte per capelli colori", "tags": [ "hair color", "product" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 1, "page": 1, "directory": "\/colorazione\/capelli-color-cioccolato-fai-da-te\/", "url": "https:\/\/www.example.it\/colorazione\/capelli-color-cioccolato-fai-da-te\/", "visibility": 0, "traffic": 8, "ad_budget": 3.28, "title": "Capelli color cioccolato: come farli comodamente a casa", "kd": 24, "traffic_volume": 56, "cpc": 0.41, "delta_traffic": 8, "trend": { "trend": 1, "abs": 1, "per": 50 }, "tags": [ "color" ] } ], "keyword": "tinta cioccolato", "tags": [ "color", "hair color" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 1, "page": 1, "directory": "\/pelle\/brufoli-mento-come-trattarli\/", "url": "https:\/\/www.example.it\/pelle\/brufoli-mento-come-trattarli\/", "visibility": 1, "traffic": 28, "ad_budget": 8.96, "title": "Brufoli sul mento: perch\u00e9 compaiono e come eliminarli", "kd": 45, "traffic_volume": 207, "cpc": 0.32, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "imperfections" ] } ], "keyword": "brufoli sul mento", "tags": [ "imperfections", "skin care" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 1, "page": 1, "directory": "\/colorazione\/bellezza\/example\/nutrisse\/", "url": "https:\/\/www.example.it\/colorazione\/bellezza\/example\/nutrisse\/5-4-castano-chiaro-ramato", "visibility": 0, "traffic": 12, "ad_budget": 3.36, "title": "Castano Pralina Castano Chiaro Ramato (5.4) - Nutrisse - example", "kd": 42, "traffic_volume": 84, "cpc": 0.28, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] } ], "keyword": "castano chiaro ramato", "tags": [ "color", "hair color" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 1, "page": 1, "directory": "\/colorazione\/capelli-color-cioccolato-fai-da-te\/", "url": "https:\/\/www.example.it\/colorazione\/capelli-color-cioccolato-fai-da-te\/", "visibility": 0, "traffic": 28, "ad_budget": 12.32, "title": "", "kd": 30, "traffic_volume": 177, "cpc": 0.44, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] } ], "keyword": "capelli cioccolato", "tags": [ "color", "hair color" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 2, "page": 1, "directory": "\/colorazione\/bellezza\/example\/belle-color\/", "url": "https:\/\/www.example.it\/colorazione\/bellezza\/example\/belle-color\/24-castano-scuro", "visibility": 0, "traffic": 16, "ad_budget": 3.2, "title": "Castano Scuro (24) - Belle Color - example", "kd": 31, "traffic_volume": 288, "cpc": 0.2, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "color" ] } ], "keyword": "castano scuro", "tags": [ "color", "hair color" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 2, "page": 1, "directory": "", "url": "https:\/\/www.example.it\/colorazione", "visibility": 1, "traffic": 8, "ad_budget": 3.6, "title": "Trova la colorazione che fa per te - Tinte per capelli - example", "kd": 31, "traffic_volume": 147, "cpc": 0.45, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "hair color" ] } ], "keyword": "colori per capelli", "tags": [ "hair color", "product" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 2, "page": 1, "directory": "", "url": "https:\/\/www.example.it\/colorazione", "visibility": 1, "traffic": 24, "ad_budget": 11.76, "title": "Trova la colorazione che fa per te - Tinte per capelli - example", "kd": 34, "traffic_volume": 409, "cpc": 0.49, "delta_traffic": 12, "trend": { "trend": 1, "abs": 2, "per": 50 }, "tags": [ "hair color" ] } ], "keyword": "tinte capelli", "tags": [ "hair color", "product" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 }, { "pos": [ { "position": 2, "page": 1, "directory": "", "url": "https:\/\/www.example.it\/colorazione", "visibility": 3, "traffic": 16, "ad_budget": 7.2, "title": "Trova la colorazione che fa per te - Tinte per capelli - example", "kd": 29, "traffic_volume": 270, "cpc": 0.45, "delta_traffic": 0, "trend": { "trend": 0, "abs": 0, "per": 0 }, "tags": [ "hair color" ] } ], "keyword": "tinte per capelli", "tags": [ "hair color", "product" ], "delete_date": "0", "date": 20180608, "trend_date": 20180601 } ], "count": 350, "balance": 189350 }

i modified the scipt in line 56 and added
$json = $json['response'];

I got a csv done this way
pos,keyword,tags,delete_date,date,trend_date Array,"biondo scuro",Array,0,20180608,20180601 Array,"tinte per capelli colori",Array,0,20180608,20180601 Array,"tinta cioccolato",Array,0,20180608,20180601 Array,"brufoli sul mento",Array,0,20180608,20180601 Array,"castano chiaro ramato",Array,0,20180608,20180601 Array,"capelli cioccolato",Array,0,20180608,20180601 Array,"castano scuro",Array,0,20180608,20180601 Array,"colori per capelli",Array,0,20180608,20180601 Array,"tinte capelli",Array,0,20180608,20180601 Array,"tinte per capelli",Array,0,20180608,20180601
how can I tell the script that must also take the keys (and values) inside the matrix?

Thanks

@mohkhz2001
Copy link

@MrZANO
can you use this for your json?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants