Home > Enterprise >  How can i get rid of "" in JSON format?
How can i get rid of "" in JSON format?

Time:09-16

I am trying to represent JSON formated data Using React library Victory here it is.

example of component:

const data = [
  {quarter: 1, earnings: 13000},
  {quarter: 2, earnings: 16500},
  {quarter: 3, earnings: 14250},
  {quarter: 4, earnings: 19000}
];

class App extends React.Component {
  render() {
    return (
      <VictoryBar
        data={data}
        // data accessor for x values
        x="quarter"
        // data accessor for y values
        y="earnings"
      />
    )
  }
}

ReactDOM.render(<App/>, mountNode);

but I get my data from API in JSON format

notice format of data:

    const data = { "historical" : [
  {"quarter": 1, "earnings": 13000},
  {"quarter": 2, "earnings": 16500},
  {"quarter": 3, "earnings": 14250},
  {"quarter": 4, "earnings": 19000}
]};

What type of array is used in first fragment?

And how can I make it from the second?

CodePudding user response:

Use data.historical as the array in your component.

  • Related