I have a JSON data object like so (stored in $json):
[{
    "Komoditas": "Beras",
    "09\/08\/2017": "10.612",
    "10\/08\/2017": "10.623",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Gula",
    "09\/08\/2017": "13.242",
    "10\/08\/2017": "13.235",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Minyak Goreng",
    "09\/08\/2017": "11.399",
    "10\/08\/2017": "11.395",
    "Sat": "Lt",
    "Ket": ""
}, {
    "Komoditas": "Tepung Terigu",
    "09\/08\/2017": "9.031",
    "10\/08\/2017": "9.026",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Kedelai",
    "09\/08\/2017": "10.775",
    "10\/08\/2017": "10.775",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Daging Sapi",
    "09\/08\/2017": "117.323",
    "10\/08\/2017": "117.372",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Daging Ayam",
    "09\/08\/2017": "33.024",
    "10\/08\/2017": "32.953",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Telur Ayam",
    "09\/08\/2017": "22.961",
    "10\/08\/2017": "22.929",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Cabe",
    "09\/08\/2017": "30.054",
    "10\/08\/2017": "29.791",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Bawang",
    "09\/08\/2017": "31.222",
    "10\/08\/2017": "31.251",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Susu",
    "09\/08\/2017": "10.446",
    "10\/08\/2017": "10.436",
    "Sat": "Gr",
    "Ket": ""
}, {
    "Komoditas": "Jagung",
    "09\/08\/2017": "7.154",
    "10\/08\/2017": "7.140",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Ikan",
    "09\/08\/2017": "76.826",
    "10\/08\/2017": "77.058",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Garam",
    "09\/08\/2017": "9.869",
    "10\/08\/2017": "10.079",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Mie Instan",
    "09\/08\/2017": "2.421",
    "10\/08\/2017": "2.428",
    "Sat": "Bks",
    "Ket": ""
}, {
    "Komoditas": "Kacang",
    "09\/08\/2017": "25.594",
    "10\/08\/2017": "25.510",
    "Sat": "Kg",
    "Ket": ""
}, {
    "Komoditas": "Ketela Pohon",
    "09\/08\/2017": "5.410",
    "10\/08\/2017": "5.380",
    "Sat": "Kg",
    "Ket": ""
}]
I want to filter it so that I only get the data from "Komoditas "**Beras", the result for the given JSON should look like this:
[{
    "Komoditas": "Beras",
    "09\/08\/2017": "10.612",
    "10\/08\/2017": "10.623",
    "Sat": "Kg",
    "Ket": ""
}]
I've tried the following code but it shows the error "Trying to get property of non-object":
 <?php
    $result = (json_decode($json));
    echo $result->Komoditas['Beras']; 
   ?>
Can anyone tell me what I'm doing wrong please? Thanks!
 
     
     
    