Accessing the Data in json object - mysql

This Works
app.get('/api/v1/admin/getAllUsers',async function (req,res,next){
try {
if (!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ') || !req.headers.authorization.split(' ')[1]) {
return res.status(422).json({ message: 'Please Provide Token!' })
}
dbConn.query('select * from fasta_users; select * from fasta_admin_users;select Name, email,password,phone,role,status,created_at from fasta_riders;', function (error, results, fields) {
if (error) throw error;
return res.send({ error: false, data: results , message: 'users list' });
});
} catch (err) {
next(err);
}
})
It returns the data i want without problems but the Json is Looking like this
{
"error": false,
"data": [
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T14:58:26.000Z"
},
{
"id": 2,
"fastaUserId": "FU-71198",
"fullname": "z",
"email": "z#gmail.com",
"password": "$2a$12$a9ibquFv477e6KL3N49JweVoiSmDXR0UVcM5xCkB39/8loKZ/u0bq",
"state": "z",
"role": "z",
"city": "user",
"phone_num": "z",
"created_at": "2022-05-17T17:57:39.000Z"
}
],
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T17:48:39.000Z"
},
{
"id": 2,
"fastaUserId": "FA-76249",
"fullname": "James Hall",
"email": "jameshallblog.com#gmail.com",
"password": "$2a$12$j711FBY441CHwacisjcL9OT9Rjb5Yll8VzdSncKJilC0Pku9i2RP2",
"phone_num": "090865735422",
"avatar": "https://oxfordssocustomerapi.azurewebsites.net/Docs/Users/OIG-00424.jpg",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-17T17:51:03.000Z"
}
],
[
{
"Name": "Karen Mitchelle",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"role": "Rider",
"status": "Active",
"created_at": "2022-05-17T14:59:22.000Z"
}
]
],
"message": "users list"
}
But I do not want this ^^^ above as a Response. I want something like this instead.
"data":[{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T15:58:26.000Z"
},
{
"id": 1,
"fastaUserId": "",
"fullname": "alex roman",
"email": "alex.roman#juno.com",
"password": "$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.",
"state": "Lagos",
"city": "city",
"phone_num": "08111111111",
"company_type": "Registered",
"company_name": "Polaris Shipping Inc.",
"company_regnum": "RC-123456",
"c_license": 1,
"role": "Delivery man",
"l_licensenumber": "LAG-2372328",
"company_address": "150 Wole Madariola Close",
"num_employees": "200",
"company_nature": "Sole Propietorship",
"created_at": "2022-05-17T15:57:41.000Z"
},
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T18:48:39.000Z"
},
{
"id": 1,
"Name": "Karen Mitchelle",
"RidersID": "FR-60842",
"Status": "Active",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"No_deliveries": "200",
"rating": "5",
"state": "Lagos",
"city": "Lagos",
"role": "Rider",
"address": "150 Wole Kolawole Str. Lagos Nigeria",
"bike_manufacturer": "Suzuki",
"bike_model": "Suzuki 400",
"bike_year": "2012",
"engine_power": "HP8",
"bike_color": "red",
"license_number": "SMK900-LA",
"license_expiry": "2027-05-01",
"vehicle_id": "LA8373Q2",
"created_at": "2022-05-17T15:59:22.000Z"
}
]
What must i do in my code above to access that data object from results in the response here like this return res.send({ error: false, data: results , message: 'users list' }); and return something like the second Json as shown above? I am trying to get this solved and nothing i have seen on the internet is being quite helpful here. Please i need help

Related

remove nested array from json array

How do i go about returning only the json without the [] from a Mysql multiple query?
I have this as an SQL Query
app.get('/api/v1/admin/getAllUsers',async function (req,res,next){
try {
if (!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ') || !req.headers.authorization.split(' ')[1]) {
return res.status(422).json({ message: 'Please Provide Token!' })
}
dbConn.query('select * from fasta_users; select * from fasta_logistics; select * from fasta_admin_users;select * from fasta_riders;', function (error, results, fields) {
if (error) throw error;
return res.send({ error: false, data: results, message: 'users list' });
});
} catch (err) {
next(err);
}
})
having run this, I get this as response :
{
"error": false,
"data": [
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T15:58:26.000Z"
}
],
[
{
"id": 1,
"fastaUserId": "",
"fullname": "alex roman",
"email": "alex.roman#juno.com",
"password": "$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.",
"state": "Lagos",
"city": "city",
"phone_num": "08111111111",
"company_type": "Registered",
"company_name": "Polaris Shipping Inc.",
"company_regnum": "RC-123456",
"c_license": 1,
"role": "Delivery man",
"l_licensenumber": "LAG-2372328",
"company_address": "150 Wole Madariola Close",
"num_employees": "200",
"company_nature": "Sole Propietorship",
"created_at": "2022-05-17T15:57:41.000Z"
}
],
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T18:48:39.000Z"
}
],
[
{
"id": 1,
"Name": "Karen Mitchelle",
"RidersID": "FR-60842",
"Status": "Active",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"No_deliveries": "200",
"rating": "5",
"state": "Lagos",
"city": "Lagos",
"role": "Rider",
"address": "150 Wole Kolawole Str. Lagos Nigeria",
"bike_manufacturer": "Suzuki",
"bike_model": "Suzuki 400",
"bike_year": "2012",
"engine_power": "HP8",
"bike_color": "red",
"license_number": "SMK900-LA",
"license_expiry": "2027-05-01",
"vehicle_id": "LA8373Q2",
"created_at": "2022-05-17T15:59:22.000Z"
}
]
],
"message": "users list"
}
I just want it to return just the json object alone. How is this possible?
Please I need a guide with this,How can I get this resolved? I need a guide with this.
is there a way to make it be like this :
{
"error":false,
"data":{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T15:58:26.000Z",
{
"id": 1,
"fastaUserId": "",
"fullname": "alex roman",
"email": "alex.roman#juno.com",
"password": "$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.",
"state": "Lagos",
"city": "city",
"phone_num": "08111111111",
"company_type": "Registered",
"company_name": "Polaris Shipping Inc.",
"company_regnum": "RC-123456",
"c_license": 1,
"role": "Delivery man",
"l_licensenumber": "LAG-2372328",
"company_address": "150 Wole Madariola Close",
"num_employees": "200",
"company_nature": "Sole Propietorship",
"created_at": "2022-05-17T15:57:41.000Z"
},
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T18:48:39.000Z"
},
{
"id": 1,
"Name": "Karen Mitchelle",
"RidersID": "FR-60842",
"Status": "Active",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"No_deliveries": "200",
"rating": "5",
"state": "Lagos",
"city": "Lagos",
"role": "Rider",
"address": "150 Wole Kolawole Str. Lagos Nigeria",
"bike_manufacturer": "Suzuki",
"bike_model": "Suzuki 400",
"bike_year": "2012",
"engine_power": "HP8",
"bike_color": "red",
"license_number": "SMK900-LA",
"license_expiry": "2027-05-01",
"vehicle_id": "LA8373Q2",
"created_at": "2022-05-17T15:59:22.000Z"
}
}
}
Edits
My code is Looking like this now :
app.get('/api/v1/admin/getAllUsers',async function (req,res,next){
try {
if (!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ') || !req.headers.authorization.split(' ')[1]) {
return res.status(422).json({ message: 'Please Provide Token!' })
}
dbConn.query('select * from fasta_users; select * from fasta_admin_users;select * from fasta_riders;', function (error, results, fields) {
if (error) throw error;
const infoz = results.data.map(arr =>arr[0]);
return res.send({ error: false, data: infoz, message: 'users list' });
});
} catch (err) {
next(err);
}
})
It still returns the nested array.
You can user Array#map() and get first user from nested array using Destructuring assignment
Code:
const response = {error: false,data: [[{id: 1,fastaUserId: '',fullname: 'John Qasim',email: 'j_qasim001#aol.com',password: '$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG',state: 'Imo',role: 'Customers',city: 'Owerri',phone_num: '08076631261',created_at: '2022-05-17T15:58:26.000Z',},],[{id: 1,fastaUserId: '',fullname: 'alex roman',email: 'alex.roman#juno.com',password: '$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.',state: 'Lagos',city: 'city',phone_num: '08111111111',company_type: 'Registered',company_name: 'Polaris Shipping Inc.',company_regnum: 'RC-123456',c_license: 1,role: 'Delivery man',l_licensenumber: 'LAG-2372328',company_address: '150 Wole Madariola Close',num_employees: '200',company_nature: 'Sole Propietorship',created_at: '2022-05-17T15:57:41.000Z',},],[{id: 1,fastaUserId: '',fullname: 'John Legend',email: 'john.legend#gmail.com',password: '$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy',phone_num: '0188272610',avatar: 'test_pic',role: 'Administrator',status: 'Active',created_at: '2022-05-11T18:48:39.000Z',},],[{id: 1,Name: 'Karen Mitchelle',RidersID: 'FR-60842',Status: 'Active',email: 'k.m.boon#gmail.com',password: '$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC',phone: '08128829102',No_deliveries: '200',rating: '5',state: 'Lagos',city: 'Lagos',role: 'Rider',address: '150 Wole Kolawole Str. Lagos Nigeria',bike_manufacturer: 'Suzuki',bike_model: 'Suzuki 400',bike_year: '2012',engine_power: 'HP8',bike_color: 'red',license_number: 'SMK900-LA',license_expiry: '2027-05-01',vehicle_id: 'LA8373Q2',created_at: '2022-05-17T15:59:22.000Z',},],],message: 'users list',}
response.data = response.data.map(([user]) => user)
console.log(response)
.as-console-wrapper { max-height: 100% !important; top: 0; }
Also you can use Array#flat()
Code:
const response = {error: false,data: [[{id: 1,fastaUserId: '',fullname: 'John Qasim',email: 'j_qasim001#aol.com',password: '$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG',state: 'Imo',role: 'Customers',city: 'Owerri',phone_num: '08076631261',created_at: '2022-05-17T15:58:26.000Z',},],[{id: 1,fastaUserId: '',fullname: 'alex roman',email: 'alex.roman#juno.com',password: '$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.',state: 'Lagos',city: 'city',phone_num: '08111111111',company_type: 'Registered',company_name: 'Polaris Shipping Inc.',company_regnum: 'RC-123456',c_license: 1,role: 'Delivery man',l_licensenumber: 'LAG-2372328',company_address: '150 Wole Madariola Close',num_employees: '200',company_nature: 'Sole Propietorship',created_at: '2022-05-17T15:57:41.000Z',},],[{id: 1,fastaUserId: '',fullname: 'John Legend',email: 'john.legend#gmail.com',password: '$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy',phone_num: '0188272610',avatar: 'test_pic',role: 'Administrator',status: 'Active',created_at: '2022-05-11T18:48:39.000Z',},],[{id: 1,Name: 'Karen Mitchelle',RidersID: 'FR-60842',Status: 'Active',email: 'k.m.boon#gmail.com',password: '$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC',phone: '08128829102',No_deliveries: '200',rating: '5',state: 'Lagos',city: 'Lagos',role: 'Rider',address: '150 Wole Kolawole Str. Lagos Nigeria',bike_manufacturer: 'Suzuki',bike_model: 'Suzuki 400',bike_year: '2012',engine_power: 'HP8',bike_color: 'red',license_number: 'SMK900-LA',license_expiry: '2027-05-01',vehicle_id: 'LA8373Q2',created_at: '2022-05-17T15:59:22.000Z',},],],message: 'users list',}
response.data = response.data.flat()
console.log(response)

Metafield is returning an error of "value":"expected Hash to be a String" when the metafield type is JSON

I'm using the Shopify customer API to create customers. It all works well until I add a metafield of type JSON. Then, I get the response {"errors":{"value":"expected Hash to be a String"}}.
Here is the entire object I'm submitting:
{
"customer": {
"accepts_marketing": "true",
"accepts_marketing_updated_at": "2022-03-01T12:45:42.770",
"currency": "USD",
"default_address": {
"zip": "91321",
"city": "SomeCity",
"phone": "5555551111",
"customerCompany": "",
"countryCode": "US",
"default": "true",
"address1": "1111 My Street",
"address2": "",
"province_code": "CA",
"last_name": "LastusNamus",
"first_name": "FirstusNamus"
},
"email": "myemail#yahoo.com",
"first_name": "FirstusNamus",
"last_name": "LastusNamus",
"created_at": "2011-12-07T00:00:00",
"marketing_opt_in_level": "single_opt_in",
"note": "",
"order_count": 0,
"phone": "5555551111",
"state": "enabled",
"tax_exempt": "false",
"verfified_email": "true",
"metafields": [{
"namespace": "customer",
"key": "kickeeinfo",
"type": "json",
"value": {
"idcustomer": "37",
"iRewardPointsAccrued": "3000",
"iRewardPointsUsed": "0",
"idCustomerCategory": "0"
}
}]
}
}
Here is the string actually being submitted:
{"customer":{"accepts_marketing":"true","accepts_marketing_updated_at":"2022-03-01T12:45:42.770","currency":"USD","default_address":{"zip":"91321","city":"SomeCity","phone":"5555551111","customerCompany":"","countryCode":"US","default":"true","address1":"1111 My Street","address2":"","province_code":"CA","last_name":"LastusNamus","first_name":"FirstusNamus"},"email":"myemail#yahoo.com","first_name":"FirstusNamus","last_name":"LastusNamus","created_at":"2011-12-07T00:00:00","marketing_opt_in_level":"single_opt_in","note":"","order_count":0,"phone":"5555551111","state":"enabled","tax_exempt":"false","verfified_email":"true","metafields":[{"namespace":"customer","key":"kickeeinfo","type":"json","value":{"idcustomer":"37","iRewardPointsAccrued":"3000","iRewardPointsUsed":"0","idCustomerCategory":"0"}}]}}
What is the API expecting to be submitted? I've tried escaping the metafield "value" object and that doesn't work. I get an "unexpected token" error at that point.
The metafield value has to be escaped and then enclosed in quotes:
{
"customer": {
"accepts_marketing": "true",
"accepts_marketing_updated_at": "2022-03-01T12:45:42.770",
"currency": "USD",
"default_address": {
"zip": "91321",
"city": "SomeCity",
"phone": "5555551111",
"customerCompany": "",
"countryCode": "US",
"default": "true",
"address1": "1111 My Street",
"address2": "",
"province_code": "CA",
"last_name": "LastusNamus",
"first_name": "FirstusNamus"
},
"email": "myemail#yahoo.com",
"first_name": "FirstusNamus",
"last_name": "LastusNamus",
"created_at": "2011-12-07T00:00:00",
"marketing_opt_in_level": "single_opt_in",
"note": "",
"order_count": 0,
"phone": "5555551111",
"state": "enabled",
"tax_exempt": "false",
"verfified_email": "true",
"metafields": [{
"namespace": "customer",
"key": "kickeeinfo",
"type": "json",
"value": "{\"idcustomer\": \"37\",\"iRewardPointsAccrued\": \"3000\",\"iRewardPointsUsed\": \"0\",\"idCustomerCategory\": \"0\"}"
}]
}
}

Custom JSON format webhook WooCommerce Wordpress

I want my Woocommerce store connected to a shipping parcel company. There is no existing WooCommerce plugin for it. I want to do it with webhooks, I had already successfully made a POST request to a URL after the order.created action. The JSON output contains all the shipping information. But I want to change the format of the JSON output.
The current JSON output is something like this.
{
"id": 605,
"parent_id": 0,
"status": "pending",
"order_key": "wc_order_5893614a8fb78",
"number": 605,
"currency": "USD",
"version": "2.6.13",
"prices_include_tax": false,
"date_created": "2017-02-02T16:41:46",
"date_modified": "2017-02-02T16:41:46",
"customer_id": 2,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "13.60",
"shipping_tax": "1.22",
"cart_tax": "1.44",
"total": "32.24",
"total_tax": "2.66",
"billing": {
"first_name": "Damandeep",
"last_name": "Singh",
"company": "",
"address_1": "1257 ",
"address_2": "Coach House Court",
"city": "Fullerton",
"state": "CA",
"postcode": "92831",
"country": "US",
"email": "daman#singhdd.com",
"phone": "(122) 274-5555"
},
"shipping": {
"first_name": "Damandeep",
"last_name": "Singh",
"company": "",
"address_1": "1257",
"address_2": "Coach House Court",
"city": "Fullerton",
"state": "CA",
"postcode": "92831",
"country": "US"
},
"payment_method": "paypal_express",
"payment_method_title": "Paypal Express",
"transaction_id": "",
"customer_ip_address": "103.41.36.35",
"customer_user_agent": "PostmanRuntime/3.0.9",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2017-02-02T08:41:46",
"date_paid": "",
"cart_hash": "",
"line_items": [
{
"id": 79,
"name": "Kaju Katli",
"sku": "SW-282",
"product_id": 491,
"variation_id": 494,
"quantity": 1,
"tax_class": "",
"price": "15.98",
"subtotal": "15.98",
"subtotal_tax": "1.44",
"total": "15.98",
"total_tax": "1.44",
"taxes": [
{
"id": 1,
"total": 1.4382,
"subtotal": 1.4382
}
],
"meta": [
{
"key": "packing-size",
"label": "Packing Size",
"value": "2lb Box"
}
]
}
],
"tax_lines": [
{
"id": 81,
"rate_code": "SALES TAX-1",
"rate_id": "1",
"label": "Sales Tax",
"compound": false,
"tax_total": "1.44",
"shipping_tax_total": "1.22"
}
],
"shipping_lines": [
{
"id": 80,
"method_title": "USPS Medium Flat Rate Box",
"method_id": "usps_medium_box",
"total": "13.60",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://ambala.webdemos.cf/wp-json/wc/v1/orders/605"
}
],
"collection": [
{
"href": "https://ambala.webdemos.cf/wp-json/wc/v1/orders"
}
],
"customer": [
{
"href": "https://ambala.webdemos.cf/wp-json/wc/v1/customers/2"
}
]
}
}
The JSON output should be something like this.
{
"name": "Gijs Boersma",
"street": "Lange laan",
"house_number": "29",
"house_number_extension": "a",
"zipcode": "9281EM",
"city": "Zevenaar",
"telephone": "0602938172",
"email": "noreply#example.com",
"reference": "Bestelling 112",
"pick_up_point": {
"uuid": "560db083-d941-425b-b3b6-b813718297e1"
},
"product": "sameday_parcel_medium",
"product_options": [
{
"option": "allow_neighbours",
"value": false
},
{
"option": "require_signature",
"value": false
},
{
"option": "age_check_18",
"value": false
},
{
"option": "perishable",
"value": true,
"max_attempts": 2
}
]
}
you can do this by the orders filter.
add_filter( 'woocommerce_rest_prepare_shop_order_object', 'change_shop_order_response', 10, 3 );
function change_shop_order_response( $response, $item, $request ) {
//Do your stuff here with the $response object.
return $response
}

angularJS JSON parsing

I am new to angularJS and trying to parse the data and display it on a page.
{
"count": 13,
"status": 200,
"statusMessage": "OK",
"userContact": [
{
"user": {
"id": 1,
"firstName": "test",
"lastName": "test",
"universityId": 1,
"email": "test#harbingergroup.com",
"password": "",
"phoneNo": "1234567890",
"gender": "M",
"userType": 1,
"medicalComments": "",
"dob": "2015-02-22",
"universityAffiliation": 1,
"cityId": "1"
},
"userContactList": {
"count": 2,
"status": 200,
"statusMessage": "OK",
"contact": [
{
"id": 2,
"userId": 1,
"firstName": "test",
"lastName": "user",
"phoneNo": "9876543210",
"email": "test#example.com"
},
{
"id": 24,
"userId": 1,
"firstName": "first1",
"lastName": "last1",
"phoneNo": "9876543210",
"email": "test#example.com"
}
]
}
}]
}
this is my JSON data.What i am trying is :
<tr ng-repeat="studentDetails in studentProfileData">
studentDetails.status for getting status and studentDetails.userContacts.firstName for first name
but I am not getting the data. What is wrong here?
Assuming that studentProfileData contains a list of users (userContact):
studentDetails.user.firstName
will contain "test"

ACS review condition failure

I'm working in an android app using Titanium appcelerator.
Now i'm trying out ACS REVIEWS .. I'm getting the whole db result , i need to filter by id. For that i tried to put Where condition ..But it doesn't working..
My Json
{
"id": "52ea3eba08a3e5704b330c2a2a",
"rating": 3,
"created_at": "2014-01-30T11:59:54+0000",
"updated_at": "2014-01-30T11:59:54+0000",
"user": {
"id": "52e5f3881356b440b4b09c805",
"created_at": "2014-01-27T05:50:00+0000",
"updated_at": "2014-01-29T04:29:49+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-27T05:50:00+0000",
"username": "Gk",
"role": "j",
"admin": "false",
"custom_fields": {
"phone": "91959454651",
"usertype": "0",
"status": "1",
"ios_deviceid": "",
"country_code": "IN",
"verify_code": "4574",
"verified": "1",
"contact_sms": "1",
"contact_message": "1",
"contact_email": "1",
"contact_phone": "0",
"android_gcmid": "APA91bE0mcScNlXbCENZ2D_9jylgwdwOJ6vYTqnI_Kzqx2lqLWblnn6mT4PJ6iZRNxUGA66Ke7RJ0CKC44DL3mturNs_w3QT7KhTVIWbQE2tJgBHU7gpzB2GG4sFGXL6LiayJ5zEn_AGhxBlw"
}
},
"reviewed_object": {
"type": "Post",
"id": "52e7800313556440b4b0aa134"
},
"custom_fields": {
}
},
{
"id": "52ea3e9d4430d0b1e0c1c16",
"rating": 3,
"created_at": "2014-01-30T11:59:25+0000",
"updated_at": "2014-01-30T11:59:25+0000",
"user": {
"id": "52e8fe464643d0b130b85f5",
"first_name": "Ganesh",
"last_name": "test",
"created_at": "2014-01-29T13:12:38+0000",
"updated_at": "2014-01-29T13:12:38+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-29T13:12:38+0000",
"username": "john",
"role": "r",
"admin": "false"
},
"reviewed_object": {
"type": "Post",
"id": "52e7800343556b4dsfsdfh3434"
},
"custom_fields": {
}
},
]
I want to filter using this id..
"reviewed_object": {
"type": "Post",
"id": "52e7800343556b4dsfsdfh3434"
}
What should i write in my WHERE Condition..
Cloud.Reviews.query({
page : 1,
per_page : 20,
where : {
rating : {
'$gt' : 1.0
},
},
order : "-created_at"
}
i have added my post id condition without where statement ..It worked perfectly..
My Code:
Cloud.Reviews.query({
page :1,
per_page : 20,
post_id : Your Post id
}, function(e) {
if (e.success) {