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

  • Home
  • SEARCH
  • 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 8602221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:01:44+00:00 2026-06-12T02:01:44+00:00

I am writing a script where I need to parse JSON in browsers that

  • 0

I am writing a script where I need to parse JSON in browsers that don’t support JSON.parse(). I have strict size objectives (total size < 20 kb) so I cannot rely on an external library like jQuery.

The usual approach would be to use eval() but I am concerned that it is not safe, as I have no control on the JSON strings (provided by an external source).

I came up with the idea to use a script tag to create my object:

var json='{"name":"Me","age":"30"}';
var scr=document.createElement("script");
scr.innerHTML="var obj="+json;
document.body.appendChild(scr);

This seems to work, as demonstrated here:
http://jsfiddle.net/bz8f7/

Am I missing something here? Are there cases where my method won’t work, or won’t be safe?

Note: I am aware that this method creates a global variable, and I am fine with that for my use case.

  • 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-12T02:01:45+00:00Added an answer on June 12, 2026 at 2:01 am

    You are still evaluating JavaScript, just by using a more complex, less efficient method than eval. It has all the safety issues of eval.

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

Sidebar

Related Questions

I'm writing a script and I need to create a loop that will execute
I am writing a Autohotkey script that need to 'check' and 'uncheck' checkboxes defined
I have been writing housekeeping script , now i need to install housekeeping script
Need help writing a script downloads data from google insight using c# this is
I am writing a Script in Python and I need to search and Replace
I'm writing a shell script and I need to strip FIND ME out of
I am writing a resume script and I need the heading Reference to be
I am writing a script in perl where I use forking and I need
I'm writing a script to check RSS feeds on regular intervals and need to
I'm writing a script for IRC and sometimes I might need to use a

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.