node.js - toJSON() does not work on a array full of json objects -


updated question

im using sails.js v0.10.5

and i'm trying use sails tojson() , im trying delete stuff server before sent client.

so have user system can write name , typeaead query database using sails backend. when suggestions sent array includes multiple users objects.

the returned object follows

[   {     "_id": "55394747d01d6777e09f4919",     "index": 0,     "guid": "1e08f17d-0163-40f6-b673-c9b1823b3e9b",     "isactive": true,     "balance": "$2,994.39",     "picture": "http://placehold.it/32x32",     "age": 28,     "eyecolor": "brown",     "name": "grant hughes",     "gender": "male",     "company": "cubix",     "email": "granthughes@cubix.com",     "phone": "+1 (972) 415-2367",     "address": "656 hornell loop, farmers, new york, 7735",     "about": "elit aute veniam commodo dolore labore ullamco reprehenderit ut exercitation magna laboris nulla. proident qui proident labore proident anim in anim reprehenderit non officia sint amet. voluptate ea amet nostrud mollit deserunt magna laboris aute laboris deserunt ea quis lorem nulla. ullamco ea aliquip laborum qui ut dolor nisi ad id irure in occaecat. dolore est amet adipisicing sit.\r\n",     "registered": "2014-04-07t02:21:28 -12:00",     "latitude": 52.890391,     "longitude": 67.80552   },   {     "_id": "55394747f2a80d1ba9b01b5e",     "index": 1,     "guid": "6030d442-b540-4879-9a2d-5faba79d67a7",     "isactive": false,     "balance": "$3,230.72",     "picture": "http://placehold.it/32x32",     "age": 28,     "eyecolor": "brown",     "name": "nolan carr",     "gender": "male",     "company": "pearlessa",     "email": "nolancarr@pearlessa.com",     "phone": "+1 (957) 464-3471",     "address": "529 laurel avenue, springville, colorado, 8055",     "about": "labore nostrud culpa ad anim ea amet. exercitation nostrud exercitation et ad. ad laboris dolore cupidatat aute lorem cupidatat consequat nulla. eiusmod ad et in laborum irure. ad ullamco sit voluptate officia officia sint magna mollit esse duis minim cillum. ex incididunt sint labore consequat id sint mollit ex incididunt pariatur laborum dolor reprehenderit.\r\n",     "registered": "2015-02-02t16:50:50 -13:00",     "latitude": -53.719292,     "longitude": -95.203951   },   {     "_id": "55394747ba2b581b96837ffd",     "index": 2,     "guid": "69edd6e6-b100-4139-bde5-afb6e4843809",     "isactive": false,     "balance": "$3,596.99",     "picture": "http://placehold.it/32x32",     "age": 33,     "eyecolor": "green",     "name": "phoebe case",     "gender": "female",     "company": "polarium",     "email": "phoebecase@polarium.com",     "phone": "+1 (850) 498-2504",     "address": "954 roder avenue, day, north carolina, 7135",     "about": "aute occaecat aute dolore proident ipsum et adipisicing adipisicing. nostrud voluptate irure in proident magna. enim anim ut esse nostrud culpa enim deserunt amet laborum cupidatat.\r\n",     "registered": "2014-08-30t23:07:38 -12:00",     "latitude": 4.607936,     "longitude": 3.118566   },   {     "_id": "5539474726b1eb741927212d",     "index": 3,     "guid": "9ac1c59b-9579-4d5a-916d-76b4e1f77ec6",     "isactive": true,     "balance": "$1,735.99",     "picture": "http://placehold.it/32x32",     "age": 31,     "eyecolor": "brown",     "name": "zimmerman holder",     "gender": "male",     "company": "snowpoke",     "email": "zimmermanholder@snowpoke.com",     "phone": "+1 (804) 472-3444",     "address": "290 rock street, eureka, wyoming, 2608",     "about": "laborum occaecat est elit irure lorem sunt eu velit proident occaecat commodo duis. dolor amet sunt labore culpa consequat consectetur officia sit veniam. sunt irure et ex sunt reprehenderit excepteur consectetur ea. nostrud id excepteur irure officia commodo.\r\n",     "registered": "2014-10-07t22:49:40 -13:00",     "latitude": 60.592749,     "longitude": -2.034919   },   {     "_id": "553947472855b7e80715fdf0",     "index": 4,     "guid": "8e67b7d2-a88b-4472-bf6b-17e893e4bb19",     "isactive": true,     "balance": "$1,264.71",     "picture": "http://placehold.it/32x32",     "age": 38,     "eyecolor": "green",     "name": "cooley mcdonald",     "gender": "male",     "company": "playce",     "email": "cooleymcdonald@playce.com",     "phone": "+1 (863) 527-3596",     "address": "741 virginia place, watrous, kentucky, 6411",     "about": "irure reprehenderit quis id cillum fugiat. qui sunt voluptate culpa anim officia occaecat consequat aute et. amet consectetur minim deserunt ea consequat nulla dolore. esse nisi commodo cillum exercitation. culpa est minim esse ad commodo ipsum sit. nostrud deserunt pariatur commodo laboris esse id officia enim mollit aliqua.\r\n",     "registered": "2014-12-15t17:15:37 -13:00",     "latitude": 31.826787,     "longitude": 168.934892   },   {     "_id": "55394747d5875e0e9847aa1f",     "index": 5,     "guid": "633d45bd-a417-44eb-b16e-4dd40b08c2fd",     "isactive": false,     "balance": "$3,369.67",     "picture": "http://placehold.it/32x32",     "age": 36,     "eyecolor": "blue",     "name": "conner foley",     "gender": "male",     "company": "essensia",     "email": "connerfoley@essensia.com",     "phone": "+1 (889) 402-3506",     "address": "864 stryker street, denio, florida, 447",     "about": "veniam esse nisi eiusmod ex lorem. duis deserunt sunt aliquip officia. consequat proident voluptate irure lorem fugiat labore. voluptate tempor officia aute dolor anim velit dolor officia mollit consequat. qui officia exercitation ut et veniam deserunt ea proident aliquip.\r\n",     "registered": "2014-08-02t02:33:46 -12:00",     "latitude": 81.51229,     "longitude": 86.08351   },   {     "_id": "5539474795bbdfa4c3f2fc80",     "index": 6,     "guid": "928c237f-6d34-4a29-ae10-121113920041",     "isactive": true,     "balance": "$1,066.25",     "picture": "http://placehold.it/32x32",     "age": 25,     "eyecolor": "blue",     "name": "imogene riggs",     "gender": "female",     "company": "zentime",     "email": "imogeneriggs@zentime.com",     "phone": "+1 (901) 508-3706",     "address": "261 vanderbilt street, chamberino, washington, 4035",     "about": "proident ex enim anim adipisicing culpa. eu qui ad mollit duis dolor do. elit cillum officia amet amet id aliqua lorem amet labore adipisicing voluptate magna. id elit amet duis consequat. voluptate excepteur dolore exercitation tempor quis id dolor ea aute. voluptate velit amet officia adipisicing cillum in aliquip ut irure ad velit lorem quis.\r\n",     "registered": "2014-06-24t09:34:41 -12:00",     "latitude": -49.444024,     "longitude": -112.470791   } ] 

i need tojson work , remove sensitive information these each user found, want sails backend send me age, name, _id frontend,client.

please help

sounds want parse database query results json can modified it.

if thats correct can use json.parse()

example:

   var usersjson = json.parse(usermodels) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -