Hi, I am going through a JSON array as a result of requesting documents in mongoDB. The thing is, I get the following behavior, and I don't know why I get this:
in key: _bsontype |value: ObjectID
in key: id |value: S÷¯çò9þ w
in key: _bsontype |value: ObjectID
in key: id |value: S÷¯çò9þ h
in key: _bsontype |value: ObjectID
in key: id |value: S÷¯çò9þ h
in key: name |value: Default Process
in key: processType |value: Public
in key: id |value: BPMNDiagram_1
in key: name |value: procurement subprocess
As you can see, this is wear and tear ... this is my code:
function changeIDs(json, map, count){
for(var key in json){
if(json.hasOwnProperty(key))
if(typeof json[key] === 'object')
changeIDs(json[key], map, count);
else{
console.log("in key: "+key + " |value: "+json[key]);
}
}
}
And this is part of my input (json parameter):
[
{
"_id": "538df78eafe7f28d39fe2077",
"processId": "538df71bafe7f28d39fe2068",
"processMeta": {
"id": "538df71bafe7f28d39fe2068",
"name": "Default Process",
"processType": "Public"
},
"diagram": {
"id": "BPMNDiagram_1",
"name": "procurement subprocess"
},
"plane": {
"id": "BPMNPlane_1",
"bpmnElement": "538df71bafe7f28d39fe2068"
}
},
{other objects..},{other objects..}
]
Yes, processId and _id are generated using the ObjectId function, and here, where the problem arises, I am not sure about this, but I assume that each _bsontype corresponds to the identifier of the mongoSB object, and this is an object, so my function passes inside this recursively .. getting next S÷¯çò9þ w.. am i right?
, "processId" "_id" , - , , _bsontype...
: , ?, , "id", , id, ObjectId.str "processId" "_id".
.