javascript - Retrieving entire json array as a string -


i using fine uploader pass params this

callbacks: {     onsubmit: function(id, filename) {         this.setparams({             a: 'adm',             b: '126',             c: {                 fileid: id,                 path:'',                 name:'',                 originalname: filename             }         });     } } 

on server side (in nodejs) retrieve entire array @ once

req.body[c] 

to string

{     fileid: id,         path:'',     name:'',     originalname: filename } 

but c comes out javascript array seems have pick each subkey 1 one with

req.body[c['fileid']], ... 

is there way in javascript/fine uploader of getting entire array name?

or @ least easier way loop through keys of array?

i'm quite sure req.body.c object, not array.

there various way pair keys/values object.

two of them for..in , object.keys()

var c = {      fileid: 1,      path:'',      name:'',      originalname: 'filename'  }    (let key in c) {    if (!c.hasownproperty(key)) continue;    console.log('key:', key, ' value:', c[key]);  }    var keys = object.keys(c);  console.log('second method:');  (let = 0; < keys.length; i++) {    console.log('key:', keys[i], ' value:', c[keys[i]]);  }

in future use object.entries() (atm works in firefox > 47 , chrome > 51):

object.entries(c).foreach(arr => console.log('key:', arr[0], ' value:', arr[1])); 

Comments