I'm receiving data on my nodejs app from a cordova app via a jQuery ajax call and it's formatted as
{
"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
{
network: {
"msisdn" : "",
...
}
}
I can loop through the object in the cordova phone app while accessing the nested keys like objectName.network.msisdn but I cannot once I receive the data in my nodejs backend.
I am posting the data as shown below
$.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));
});
I would like to access the sub keys from the object.
I have tried Json.Parse(Json.stringify(objectName)) before posting the data,
I have also tried to post without the json dataType in the jQuery ajax call,
I have tried to JSON.parse( ) the object in the back end all to no avail.
I really appreciate your assistance.
network[msisdn])?