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 8655031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:55:55+00:00 2026-06-12T14:55:55+00:00

I need it because I recently made an app that saves an object containing

  • 0

I need it because I recently made an app that saves an object containing all the user-generated data to localStorage, and encodes/decodes it with JSON.

The bizarre thing is that for some reason, Internet Explorer has poor, if not zero, support for JSON (“JSON is not defined”), and I’m not up to trying to re-create the entire function.

stringify:function(x){
    y='{'
    for(i in x){
        reg=RegExp('\'','g')
        y+=',\''+i.replace(reg,'\\\'')+'\':\''+x[i].replace(reg,'\\\'')+'\''
    }
    y=y.replace(',','')
    y+='}'
    return y
}

This was my first attempt, but I had forgotten that the object has other objects inside it, which themselves contain objects, and kept getting an error which basically stemmed from trying to call the method String.prototype.replace() of an Object.

Since I was kinda OCD with my code at the time, I actually do have the structure of the object saved in the source code:

/*
Link Engine.data: Object: { 
    X: Object: {    [Each is a Paradigm, contains links]
        link.0:{
            link:[link],
            title:[title],
            removed:[true/false],
            starred:[true/false]
        },
        ...
    },
    LSPAR: [Reserved] Object: { [Paradigm list and pointer contained here]
        key:[key], (this controls X)
        list:{
            [listitem]:[listitem],
            ...
        }
    },
    #CONFIG: [Reserved] Object: { [contains miscellaneous Config data]
        property:boolean/number/string,
        ...
    }
*/

That’s the basic data structure, ... represents a repeating pattern.


Edit 2019

This whole question is an abomination, but I want to at least attempt to fix the bothersome documentation I wrote for my poorly-designed data structure so that it’s more coherent:

Link {
    string  link
    string  title
    boolean removed
    boolean starred
}

Config {
    ...

    /* Just has a bunch of arbitrary fields; not important */
}

WArray {
    string... [paradigm-name]

    /* Wasteful Array; an object of the form
     * { "a":"a", "b":"b", ... }
     */
}

Paradigm { /* analogous to above "X: Object: {..." nonsense */
    Link... [paradigm-name].[id]

    /* each key is of the form [paradigm-name].[id] and stores a Link
     * e.g. the first link in the "Example" paradigm would
     * be identified by the key "Example.0"
     */
}

ParadigmList {
    string key  /* name of selected paradigm */
    WArray list /* list of paradigm names */
}

LinkEngineData {
    Paradigm...   [paradigm-name]
    ParadigmList  LSPAR
    Config        #CONFIG /* actual field name */
}

Hopefully now you can sort of parse what’s going on. This syntax:

type... format

is meant to convey that objects of type type appear many times, like an array, except it isn’t an array. As such, the fields don’t have a name that is set-in-stone, hence

format: [descriptor1]text[descriptor2]text...

a format is used in place of an actual field name. This is what happens when you try to create a data structure without knowing what a data structure is. I did use the words “data” and “structure” adjacently in the original question, but it was pure coincidence. I didn’t mean it like “this is the data structure I used”; I meant it like “this is the structure of my data”.

Anyways, here’s how I would design it today:

Link {
    string  url
    string  title
    boolean starred
}

LinkGroup {
    string name
    Link[] links
}

Config {
    ... /* has whatever it needs to have */
}

Data {
    int         selGroup
    LinkGroup[] groups
    Config      config
}

That is all.


If someone has the sourcecode of the actual JSON.stringify function, or knows a way to replicate it, then please put your answer.


EDIT (2013, probably)

I ended up dropping IE support and completely redesigning the app from the ground up; the new version is hosted here. And it works with IE9 out of the box!

  • 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-12T14:55:57+00:00Added an answer on June 12, 2026 at 2:55 pm

    I think this is the best replacement: http://bestiejs.github.com/json3/

    It claims to be better than Crockford’s JSON 2 for the following reasons (from their site):

    JSON 3…

    • Correctly serializes primitive wrapper objects (Issue #28).
    • Throws a TypeError when serializing cyclic structures (JSON 2 recurses until the call stack overflows).
    • Utilizes feature tests to detect broken or incomplete native JSON implementations (JSON 2 only checks for the presence of the native functions). The tests are only executed once at runtime, so there is no additional performance cost when parsing or serializing values.

    In contrast to JSON 2, JSON 3 does not…

    • Add toJSON() methods to the Boolean, Number, and String prototypes. These are not part of any standard, and are made redundant by the design of the stringify() implementation.
    • Add toJSON() or toISOString() methods to Date.prototype. See the note about date serialization below.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently had the need to use the managers compiler argument, because the project
I need to know because I have to explicitly close some remote resources that
I am overriding sessionscontroller because I need a special behavior. When the user signs
Recently, I had the need for a function that I could use to guarantee
I recently had an app rejected from the app store because of Low Memory
I've been reading about MVC a lot recently, because I need to learn how
I recently made a new tablespace and associated a user with it (sonar). Currently,
I recently made a question based on doing a HTTP request with POST data
I must have uninstalled something recently because the Data Connections no longer work. When
I need this because the constructor in the superclass is calling a method which

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.