When my nodejs app receives data from a cordova app through a jQuery ajax call, the format is different. It looks like this:
{
"network[msisdn]": "+254738XXXXXX",
"network[country]": "ke",
"network[roaming]": "false",
"network[simState]": "Ready",
"network[network]": "HSPA",
"network[simSerial]": "89254031021032011310",
"network[subscriber]": "639031023201131",
"network[service]": "GSM"
}
Instead of the usual format:
{
network: {
"msisdn" : "",
...
}
}
While I can easily loop through the object in the cordova app to access nested keys like objectName.network.msisdn, I face challenges doing so in my nodejs backend.
When posting the data, I use the following method:
$.ajax({
url: 'http://'+$scope.api.host+':'+$scope.api.port+'/notices',
method: 'POST',
dataType: 'json',
data: $scope.storage.history[0]
}).then(function(response){
//! STORE THE RESULT IN THE RELEVANT OBJECT
$scope.storage.history[nextPos].locale = response;
alert(JSON.stringify(response));
});
My goal is to access the sub keys from the object. However, I have tried various methods such as using Json.Parse(Json.stringify(objectName)) before posting the data, removing the json dataType in the jQuery ajax call, and trying to JSON.parse( ) the object in the backend without success.
I would greatly appreciate any assistance you can provide.