google apps script - SELECT or Filter from JSON(?) Array -


i have call large json data set. has multiple items , each item has multiple pieces of information. want output 1 item's single piece of information. need filter down information 1 item or use select statement such might in sql. tried following, receive error: error: typeerror: cannot find function filter in object [object object]. (line 28, file "gwspidy api"). can't life of me figure out how boil data down 1 item. hard test code in google apps scripting.

function test3(itemid) {   var myurl = "http://www.gw2spidy.com/api/v0.9/json/all-items/all";   var jsondata = urlfetchapp.fetch(myurl);   var jsonstring = jsondata.getcontenttext();   var jsonarray = json.parse(jsonstring).result;   var jsonfilter = jsonarray.filter(function(itemid,jsonarray){if(jsonarray.data_id.match(itemid)) {return itemid;}});   var adjustedvalue = (jsonfilter.min_sale_unit_price / 100);   return adjustedvalue;   } 

also, secondary question regards cache service. asked previous question, , directed towards using cache service. unfortunately has data size limit. how might go saving array data_id , min_sale_unit_price lower size of data set.

thanks ahead of time help!

a option use scriptdb services, if amount of data great, you'll run faster problems of limits of quotas of service.

from example, following works:

var json = json.parse('{"result": [{"id": 1, "value": "value1"}, {"id": 2, "value": "value2"}]}').result;  var items = json.filter(function(item) {   if(item.id === 2) {     return item;   } });  logger.log(items); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -