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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:03:40+00:00 2026-06-13T13:03:40+00:00

My Google Chrome extension uses JSON.parse(oldJSONstring) to create an object with configuration information. The

  • 0

My Google Chrome extension uses JSON.parse(oldJSONstring) to create an object with configuration information. The “oldJSONstring” was saved from previous sessions on Chrome’s localStorage.

As I sometimes add new features, after I create the new object, I manually validate that all configuration entries exist, if not, I’ll set them with default values. This is done, in case it’s he firs time a user loads the extension after it updated.

I was trying to think of a more automatic way of doing this, like using a JSON Schmea, but I really don’t know where to start, and my first round of google searches didn’t produce anything I could use.

Another approach I thought was to iterate on all my Default settings -also stored on a JSON object- and then confirming they exist on the new object… but I just realized I don’t know how to iterate a JSON object for all its attributes 🙂

The end goal of this is that I’d like to forget about validating for new attributes, every time I create a new feature and I publish a new version… does it make any sense? does it make me lazy? 😀

Thanks!

  • 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-13T13:03:40+00:00Added an answer on June 13, 2026 at 1:03 pm

    Keep the default object handy and use jQuery $.extend to merge the 2 objects.

    var defaults={ color:'blue', size:'Large'}
    
    var chromeObj= /* code to grab from storage*/
    /* update chromeObj with all key/value pairs in defaults */
     /*  regardless if they already exist or not*/
    $.extend( chromeObj, defaults}
    
    /* code to put chromeObj back to storage*/
    

    Refrence: http://api.jquery.com/jQuery.extend/

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

Sidebar

Related Questions

I'm writing a google chrome extension that uses chrome.pageCapture.saveAsMHTML(object details, function callback) function callback
I'm writing a Google Chrome extension. As the JavaScript files are loaded from disk,
I'm trying to upload an image to Picasa from a Google Chrome Extension and
I'm making a Google Chrome Extension that uses context menus as its main UI.
I am using jQuery with a Google Chrome extension popup. The pop-up page uses
I am working on a Chrome extension that tracks time, and uses Google App
I'm working on a browser extension (google chrome and firefox) which uses content script
I'm developing a Google Chrome extension, which produces an error I can't fix. My
In my Google Chrome extension, I'm using this nifty little trick to distinguish the
I am making a Google Chrome extension and I would like to have my

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.