Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
How to use a string data as object?

I am new to software development. I am writing an application with React native. I am receiving data from the backend as follows. Actually the data is much bigger but I put a small piece of it.

For example, I want to use the first element in the array as data.Terms[0] Or I need to use the incoming data with .map. But I can't do any of these. When I do JSON.parse, I get the error Error: JSON.parse requires at least one parameter

What do I do to use this data in the ways I specified?

import React from "react";
import { View } from 'react-native';

export default Dropdown = ({ }) => {

    const data = {
        "Terms": "[{\"TermId\":\"12\",\"time\":\"10:00\"},{\"TermId\":\"13\",\"time\":\"13:00\"}]"
    }

    return (
        <View>
        </View>
    )
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you have mixed a json object and json string in your data. You can only parse a json string, not a json object. So to read data try this

const data = {
  "Terms": "[{\"TermId\":\"12\",\"time\":\"10:00\"},{\"TermId\":\"13\",\"time\":\"13:00\"}]"
}

var terms= JSON.parse(data.Terms);
console.log(terms);

var time=terms[0].time; // 10:00
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!