I'm encountering difficulties when attempting to access a specific JSON element that I receive in response from a query made into a Parse.com Class.
Despite reading through various questions and answers on similar topics, I have yet to find a solution.
Below is the code snippet for my query:
Parse.Cloud.define("todoenuno", function(request, response) {
var User = Parse.Object.extend("_User");
var query = new Parse.Query(User);
query.equalTo("TipoUsuario", {"__type": "Pointer", "className": "Tipo_de_Usuario", "objectId": "UgTuNHEQEZ"});
query.find({
success: function(results) {
response.success(results[0]);
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
response.error('Request failed with response code ' + error.status);
}
});
});
When I call the function todoenuno()
, I receive the following JSON object:
{
"result": {
"Apellido": "Galli",
"Nombre": "Gabriel",
"NombreSede_FK": {
"__type": "Pointer",
"className": "Sedes",
"objectId": "JNMeQHySaD"
},
...
// As per the original text
...
}
}
Although the query results are correct, I am struggling to extract individual elements from it.
For instance, I want to retrieve the value "Galli".
I attempted methods like:
response.success(results[0].Apellido); //or response.success(results[0]["Apellido"];
Unfortunately, these returned an empty JSON object.
If I try:
response.success(results.result.Apellido);
I encounter an error stating "Can't read 'Apellido' from undefined..."
As a beginner programmer, I apologize if this question seems trivial, but despite extensive research, I have been unable to find a suitable solution among similar discussions.
Thank you in advance for your assistance, and pardon my limited English proficiency!