Have struggled with this problem now few hours and got nothing which works..
I have a files called categories.json and index.php. In index.php i trying to get specified data from categories.json. I can get all data from there with this:
if( isset($_GET['categories_json']) ){ // TÄLLÄ SAA KAIKKI TIEDOT
//json file as is
header("Content-Type: application/json; charset=UTF-8");
$f = file_get_contents('categories.json');
echo $f;
}
And I have this kind of products in categories.json:
{
"categories": [
{
"categoryName": "Nappaimistot",
"products": [
{
"name": "Logitech K270",
"productid": 1,
"productpic_url": "https://cdn.verk.net/576/images/33/2_145225-700x423.jpeg",
"category": "Nappaimistot",
"price": 18.9,
"weight": 0.2
},
{
"name": "Logitech super keyboard",
"productid": 2,
"productpic_url": "https://cdn.verk.net/576/images/33/2_145225-700x423.jpeg",
"category": "Nappaimistot",
"price": 228.9,
"weight": 12
}
]
},
{
"categoryName": "Hiiret",
"products": [
{
"name": "Logitech MX Master 2S",
"productid": 6,
"productpic_url":"https://cdn.verk.net/960/images/91/2_404981-1640x2500.jpeg",
"category":"Hiiret",
"price": 99.90,
"weight": 0.1
}
]
},
{
"categoryName": "Naytot",
"products": [
{
"name": "Samsung C27JG50 27",
"productid": 11,
"productpic_url":"https://cdn.verk.net/960/images/91/2_404981-1640x2500.jpeg",
"category":"Naytot",
"price": 299.90,
"weight": 11
}
]
}
]
}
Example if i want all products from categoryName Nappaimistot, which price are over 20. I would preciate if you give me some glue. I got headache of this couple hours ago.