0

Example i have this:

'[{
   "_id" : ObjectId("ewfg4wefewefefw"),
   "student":
   [{
       "_id" : ObjectId("rvro43jroorvke"),
       "fname": "someone"
       "score": 3.5
   },
   {
      "_id" : ObjectId("fnoierlj4e"),
      "fname": "random"
      "score": 3.5
   },
   {
      "_id" : ObjectId("f32023wkjlew"),
      "fname": "the one"
      "score": 3.5
   }]
}]'

and I only want the result is the the one:

'{
   "_id" : ObjectId("f32023wkjlew"),
   "fname": "the one"
   "score": 3.5
}'

I think this situation is get object inside array. I tried to serach few place and cant find the one working for me. I am using monk to connect to db.

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321
  • You can iterate the array and get one by one. BTW your expectation is not valid JSON either you can convert in object or use one by one – abdulbarik Sep 21 '16 at 01:07

1 Answers1

0

To access an element of an array you have to call arrName[index starting at 0]. Try student[2]

Joey Wood
  • 273
  • 1
  • 10