mercredi 1 avril 2015

What would be the MongoDB command to save the following JSON?


Vote count:

0




I am trying to put or save some of the data within MongoDB. The output or JSON for the result should be:



[
{
"Name": "Android",
"Devices": [
{
"DName": "Moto G",
"DAttributes": {
"Dimensions": {
"Resolution": "720 x 1280 pixels;1",
"SimType": "GSM+GSM",
"DualSim": "true;2"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "false",
"PNGAlpha": "false",
"BMP": "true"
},
"Memory": {
"Internal": "16GB;1",
"RAM": "1GB;1",
"CardSlot": "true"
}
}
},
{
"DName": "Moto E",
"DAttributes": {
"Dimensions": {
"Resolution": "540 x 960 pixels;2",
"SimType": "GSM+GSM",
"DualSim": "true;2"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "false",
"PNGAlpha": "false",
"BMP": "true"
},
"Memory": {
"Internal": "4GB;3",
"RAM": "1GB;1",
"CardSlot": "true"
}
}
},
{
"DName": "Moto X",
"DAttributes": {
"Dimensions": {
"Resolution": "720 x 1280 pixels;1",
"SimType": "GSM",
"DualSim": "true;2"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "false",
"PNGAlpha": "false",
"BMP": "true"
},
"Memory": {
"Internal": "16GB;1",
"RAM": "2GB;2",
"CardSlot": "false"
}
}
},
{
"DName": "Samsung Galaxy Y",
"DAttributes": {
"Dimensions": {
"Resolution": "240 x 320 pixels;4",
"SimType": "GSM",
"DualSim": "false;1"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "false",
"PNGAlpha": "false",
"BMP": "true"
}
}
}
]
},
{
"_id": {
"$oid": "54dc633d7ee079bda4dc1193"
},
"Name": "iOS",
"Devices": [
{
"DName": "iPhone5",
"DAttributes": {
"Dimensions": {
"Resolution": "320 x 480 pixels;3",
"SimType": "GSM",
"DualSim": "false;1"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "true",
"PNGAlpha": "true",
"BMP": "true"
},
"Memory": {
"Internal": "16GB;1",
"RAM": "256MB;2",
"CardSlot": "false"
}
}
},
{
"DName": "iphone",
"DAttributes": {
"Dimensions": {
"Resolution": "320 x 480 pixels;3",
"SimType": "GSM",
"DualSim": "false;1"
},
"Image_Formats": {
"JPEG": "true",
"GIF": "true",
"TIFF": "true",
"PNGAlpha": "true",
"BMP": "true"
},
"Memory": {
"Internal": "16GB;1",
"RAM": "256MB;2",
"CardSlot": "false"
}
}
}
]
},
{
"_id": {
"$oid": "54dc63457ee079bda4dc1194"
},
"Name": "Windows",
"Attribute": [
{
"Height": "400",
"Width": "400"
}
]
},
{
"_id": {
"$oid": "54dc634a7ee079bda4dc1195"
},
"Name": "Blackberry",
"Attribute": [
{
"Height": "200",
"Width": "200"
}
]
},
{
"_id": {
"$oid": "54dc634a7ee079bda4dc1195"
},
"Name": "Palm OS",
"Attribute": [
{
"Height": "200",
"Width": "200"
}
]
},
{
"_id": {
"$oid": "54dc634a7ee079bda4dc1195"
},
"Name": "Symbian",
"Attribute": [
{
"Height": "200",
"Width": "200"
}
]
}
]


The following is the hierarchy of the JSON format i want to obtain after inserting data into MongoDB. I know the command db.table_name.save(), However I am confused about the {}'s and []'s.



asked 51 secs ago







What would be the MongoDB command to save the following JSON?

Aucun commentaire:

Enregistrer un commentaire