Formatting Data Outputs

Options

How would I format my output data such that it looks like this:

[{label:'One', value:1}, {label:'Two', value:2}]

the string would column's value in a table and the integer would be a row id.

Tagged:

Answers

  • Max
    Max Member
    Options

    your string is an [] array and inside you have objects {} with just one key:value, so you can for example create an empty variable array [], and then use filter "push" , or dedicated Array operations in crud to sort of assemble your array with {objects} you get in your function steps or however are you getting that key:value pairs

  • NWold
    NWold Member
    Options

    I am unsure if I am following along. This is the data I am working with:

    The value is id and the label is yearname. How would I start pushing this data into one of the options you specified?

  • Max
    Max Member
    Options

    if i understand you - then you can loop for through that array, and form a key:value pair from each iteration that will look like 1:"First Year", and as i said before - push each of them to new variable empty array.

    hope that makes sense

  • NWold
    NWold Member
    Options

    So what I did instead was create a function within my front end to take these values into an array. It seems to be working now from what I can see. Thank you for the help though!