Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Get Objects From String

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #190699
    justdan
    Participant

    Hey guys. I have an array that has objects stored in it as strings:

    [“{“fname”:”This”,”lname”:”Guy”,”state”:”AR”}{“fname”:”That”,”lname”:”Guy”,”state”:”CA”}”]

    I’m trying to split the objects inside of this array so that I can access the fname, lname, and state keys and values. I thought that I’d need to split the array so I can then parse over the objects and use them like a regular object (example: Object[i].fname). However, when I try to split the array at the ‘}’, it tosses an error that “undefined is not a function”. How do I go through that array and get it so that the objects aren’t in a string and will be separated? Also, please don’t think I’m asking anyone to write code or do my job for me. I have code written up that I’m currently testing which I can post if it will help someone help me, but I wanted to keep this post as clean as I could without code dumping all over the place. Any tips I can get are always appreciated. Thanks for your time.

    #190700
    shaneisme
    Participant

    Instead of a code dump, just put it up on Codepen. We can fork it and modify it from there. Hopefully it’s just a syntax error.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.