Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:10:24+00:00 2026-06-15T00:10:24+00:00

I have a string that is JSON values separated by /r. It’s sort of

  • 0

I have a string that is JSON values separated by /r. It’s sort of like records in a DB table. It looks like:

“{“id”:”id”,”hole”:”hole”,”stat”:”stat”,”value”:”value”}/r{“id”:1354075540949,”hole”:”1″,”stat”:”score”,”value”:”4″}/r{“id”:1354075540949,”hole”:”1″,”stat”:”putts”,”value”:”1″}/r{“id”:1354075540949,”hole”:”1″,”stat”:”fir”,”value”:”y”}/r{“id”:1354075540949,”hole”:”1″,”stat”:”gir”,”value”:”n”}/r”

The first row is the column names (id, hole, stat, value) and I just give them the same value. All other rows separated by /r is the actual data.

I split this string by /r, then loop through the result and push the result of JSON.parse() of each element to an array so now I have an array of objects with properties of the given structure (id, hole, stat, value). Everything is working except the ‘id’ field ends up being true or false instead of the big long number. Why is it doing that?

var tblData = localStorage.getItem(tblName).split("/r");
var data = new Array();

// fill the array
for (i = 1; i < tblData.length - 1; i++)
    data.push(JSON.parse(tblData[i]));

[EDIT]
Seems this does work, but there is a jQuery.grep() I run right after this that’s setting the id properties to true/false.

var changeRecords = jQuery.grep(data, func);

Where func is:

function (v) { return v.id == gCurrentRoundID && v.hole == gCurrentHole; }

Not sure why it would be setting id to true/false though.

[EDIT2]

Nevermind, I found my error. The function above wasn’t the right one and the one I did have only had 1 equal sign for v.id = gCurrentRoundID, which is why it was setting it to true/false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:10:26+00:00Added an answer on June 15, 2026 at 12:10 am

    I would just manually change the whole string to valid JSON. Have it start with a [ and end with a ], then replace all those /rs with commas. The end result should look like

    “[{“id”:”id”,”hole”:”hole”,”stat”:”stat”,”value”:”value”},{“id”:1354075540949,”hole”:”1″,”stat”:”score”,”value”:”4″},{“id”:1354075540949,”hole”:”1″,”stat”:”putts”,”value”:”1″},{“id”:1354075540949,”hole”:”1″,”stat”:”fir”,”value”:”y”},{“id”:1354075540949,”hole”:”1″,”stat”:”gir”,”value”:”n”},]”

    Then parse that through JSON.parse

    Just note that that last trailing comma may cause problems in IE8. If so, you should be able to manually fix that fairly easily. Something like s = s.substr(0, s.length - 2) + ']';

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON string that I would like to include as a value
I have a JSON string that looks like this: { package1: { type: envelope,
Ok..so i have a json string (myJson) that looks like this: {id: 1, file:
I have a JSON string that has 1-n numbers of lat/lng records. It looks
I have a JSON string that contains some key with the following value: 123.00.
I have a json string that contains the values for a datetime and a
I have a json that looks like this {abcd: { id: 1234, response: authenticated,
I have JSON string that has nested objects with dynamic names that vary each
How do you make JS think that a string is JSON ? I have
I have a VB6 application that is creating a JSON string and posting it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.