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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:32:54+00:00 2026-05-26T17:32:54+00:00

I have some JSON which has been passed from a servlet and is stored

  • 0

I have some JSON which has been passed from a servlet and is stored in xmlhttp.responseText. I want to decompose this JSON so that i can have values of data, size, style, name, etc. Also I wish to have the widget value to be in separate variable.

Here is the JSON:

{
  "widget vlaue=2": {
    "debug": "on",
    "window": {
      "title": "Sample Konfabulator Widget",
      "name": "main_window",
      "width": 500,
      "height": 500
    },
  },
  "image": { 
    "src": "Images/Sun.png",
    "name": "sun1",
    "hOffset": 250,
    "vOffset": 250,
    "alignment": "center"
  },
  "text": {
    "data": "Click Here",
    "size": 36,
    "style": "bold",
    "name": "text1",
    "hOffset": 250,
    "vOffset": 100,
    "alignment": "center",
    "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
  }
}    

I have tried this:

obj = JSON.parse(xmlhttp.responseText); 

but this failed. I could not find anything related to it online. Can anyone please help me with this?

  • 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-05-26T17:32:54+00:00Added an answer on May 26, 2026 at 5:32 pm

    From json.org :

    To convert a JSON text into an object, you can use the eval()
    function. eval() invokes the JavaScript compiler. Since JSON is a
    proper subset of JavaScript, the compiler will correctly parse the
    text and produce an object structure. The text must be wrapped in
    parens to avoid tripping on an ambiguity in JavaScript’s syntax.

    var myObject = eval(‘(‘ + myJSONtext + ‘)’);

    However JSON.parse is still recommended:

    The eval function is very fast. However, it can compile and execute
    any JavaScript program, so there can be security issues. The use of
    eval is indicated when the source is trusted and competent. It is much
    safer to use a JSON parser. In web applications over XMLHttpRequest,
    communication is permitted only to the same origin that provide that
    page, so it is trusted. But it might not be competent. If the server
    is not rigorous in its JSON encoding, or if it does not scrupulously
    validate all of its inputs, then it could deliver invalid JSON text
    that could be carrying dangerous script. The eval function would
    execute the script, unleashing its malice.

    To defend against this, a JSON parser should be used. A JSON parser
    will recognize only JSON text, rejecting all scripts. In browsers that
    provide native JSON support, JSON parsers are also much faster than
    eval. It is expected that native JSON support will be included in the
    next ECMAScript standard.

    var myObject = JSON.parse(myJSONtext, reviver);

    Perhaps there is something wrong with your JSON, visit jsonlint.com for a free web-base JSON validator.

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

Sidebar

Related Questions

I have some json-code which has multiple objects in it, as such: [ {
I have some JSON returned to the browser like this product: { Title: School
I have an jQuery JSON request, that loads some JSON from another server (ex.
I have a website where an ajax call will get some Json data from
I have a spring action that I am rendering some json from the controller,
I have some json files with 500MB. If I use the "trivial" json.load() to
I have an iPhone app that uses the json-framework . I moved some of
After searching through some existing libraries for JSON, I have finally ended up with
I am trying to output some Java objects as JSON, they have List properties
I'm trying to generate a JSON response that includes some HTML. Thus, I have

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.