0

I got this JSON and I want to iterate over all inner fields inside machine: machine.id (inner machine objects, one by one and get the id)

{
    "_id" : ObjectId("60b72eb607d158d886626648"),
    "accountId" : "10304",
    "dayKey" : 20210602,
    "twin" : "c9750367-36fe-4e1f-a9bb-54f44c1cd8d8",
    "ttl" : ISODate("2021-06-02T07:09:37.515Z"),
    "machines" : {
        "dff2a2c3-6765-425a-8cb8-26b3f9c6214d-machine-54652" : {
           
            "ioSize" : [ 
                14.7014119238827, 
                14.1548860858939, 
                14.5505302898045, 
                15.554507463338, 
                14.4255739350559, 
                14.5063722067039, 
                15.459819090433, 
                14.3030780813547, 
                14.1884056389665, 
                14.4948280377095, 
                13.3577492143855, a
                14.7608731232542, 
                15.9873265101257, 
                13.4887886260475, 
                15.7738139402933, 
                15.9362888442737, 
                14.7705187238128
            ],
            "id" : "dff2a2c3-6765-425a-8cb8-26b3f9c6214d.machine-54652"
        },
        "dff2a2c3-6765-425a-8cb8-26b3f9c6214d-machine-35562" : {
            
            "ioSize" : [ 
                37.7397106319832, 
                38.9988270338687, 
                38.5746933921089, 
                38.0871104661313, 
                39.2368627793296, 
                38.5768210981145, 
                40.0075015275838, 
                38.4587879713687, 
                38.7158966916899, 
                38.8449393331006, 
                38.9401787273045, 
                38.6076837465084, 
                39.5514468400838, 
                46.7157111993715, 
                48.3111469972067, 
                38.5859375, 
                38.9902398306564
            ],
            "id" : "dff2a2c3-6765-425a-8cb8-26b3f9c6214d.machine-35562"
      
        }
    }
}
turivishal
  • 34,368
  • 7
  • 36
  • 59
  • you mean like https://stackoverflow.com/questions/9329446/for-each-over-an-array-in-javascript/9329476?r=SearchResults&s=1|553.2834#9329476 – Joe Jun 29 '21 at 01:30
  • This is a MongoDB query issue, it might be that in the end Ill need to execute an external script. – danberke Jun 29 '21 at 09:18
  • MongoDB queries aren't really good for iteration. What is it you are trying to accomplish? – Joe Jun 29 '21 at 09:27

0 Answers0