Formating json output.

12 views
Skip to first unread message

Jaison N.A.

unread,
May 28, 2016, 7:39:45 AM5/28/16
to mongodb-dev
Hi,

I have a document as below.

db.QtrPatchesNew.insert(     
   {
     "Qtr": "Jan2016",
     "Patches": [ 21948347, 21948348, 21948355] ,
"PatchScripts": [ { "1": "script1.ksh" , "2": "script5.ksh" , "3": "script6.ksh" } ]
     }
  )

If i executed  find command i get details as follows.

> db.QtrPatchesNew.find( {"Qtr": "Jan2016"}, { "PatchScripts": 1, "_id": 0 } ).pretty()
{
        "PatchScripts" : [
                {
                        "1" : "script1.ksh",
                        "2" : "script5.ksh",
                        "3" : "script6.ksh"
                }
        ]
}
>

Could you please someone help me print output like 

1:script1.ksh
2:script5.ksh
3:script6.ksh

Appreciate your help.

Thanks in advance.
Jaison

Asya Kamsky

unread,
May 30, 2016, 11:27:33 PM5/30/16
to mongo...@googlegroups.com
This list is for developers *of* MongoDB - please ask your question on
MongoDB-user Google Group.

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-dev...@googlegroups.com.
> To post to this group, send email to mongo...@googlegroups.com.
> Visit this group at https://groups.google.com/group/mongodb-dev.
> For more options, visit https://groups.google.com/d/optout.



--
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
Free MongoDB Monitoring - cloud.mongodb.com
Free Online Education - university.mongodb.com
Get Involved - mongodb.org/community
We're Hiring! - https://www.mongodb.com/careers
Reply all
Reply to author
Forward
0 new messages