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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:44:03+00:00 2026-06-03T03:44:03+00:00

var jsn=getAttr(ref,json-data).toString(); console.log(jsn); //{test: true,stringtest:hallo}. it’s OK. JSON.parse(jsn); //Uncaught SyntaxError: Unexpected token s, line:

  • 0
var jsn=getAttr(ref,"json-data").toString();
console.log(jsn); //{test: true,stringtest:"hallo"}. it's OK.
JSON.parse(jsn); //Uncaught SyntaxError: Unexpected token s, line: line with JSON.parse;

I think JSON.parse does something not right with this data.. I tried to remove stringtest:"hallo" – no result… PS: also I think that I do something wrong then I have asked this question

At the first time I tried JSON.parse("{"+jsn+"}");.

  • 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-03T03:44:05+00:00Added an answer on June 3, 2026 at 3:44 am

    Your JSON is not properly formatted, as your object keys must be surrounded by quotation marks. The following will work:

    var jsn = '{"test": true, "stringtest": "hallo"}';
    JSON.parse(jsn);
    

    Edit: The RFC4627, which specifies JSON format, states:

    2.2. Objects

    An object structure is represented as a pair of curly brackets
    surrounding zero or more name/value pairs (or members). A name is a
    string
    . A single colon comes after each name, separating the name
    from the value. A single comma separates a value from a following
    name. The names within an object SHOULD be unique.

      object = begin-object [ member *( value-separator member ) ]
      end-object
    
      member = string name-separator value
    

    As you can see, JSON objects are composed of name/value pairs, where a name is a string. Again, the RFC says:

    The representation of strings is similar to conventions used in the C
    family of programming languages. A string begins and ends with
    quotation marks
    . All Unicode characters may be placed within the
    quotation marks except for the characters that must be escaped:
    quotation mark, reverse solidus, and the control characters (U+0000
    through U+001F).

    string = quotation-mark *char quotation-mark

    quotation-mark = %x22 ; “

    So, according to the RFC, keys must be surrounded by double quotes, not single one. Still, I guess some parsers may be more tolerant and accept both of them, but I’d stick to the standard.

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

Sidebar

Related Questions

var origtext = Aes.Ctr.decrypt(recentPatientsFile.read().text, 'L0ck it up saf3', 256); var recentPatientsList = JSON.parse(origtext); while
var AppPatientsList = JSON.parse(JSON RESPONSE); var AppPatientsListSort = AppPatientsList.sort(function(a,b){ return a.firstName.toLowerCase() <b.firstName.toLowerCase() ? -1
var parser = new DOMParser(), d = parser.parseFromString('<?xml version=1.0?><div class=a>Hello</div>', 'application/xhtml+xml'); console.log(d.querySelector('*')); console.log(d.querySelector('div')); console.log(d.querySelector('div.a'));
var str=itss[BACK][BACK][BACK][BACK][BACK][BACK] it's a test stringgg[BACK][BACK]; var word = '[BACK]'; var substrings = str.split(word);
var data = { message: Posting SWF using FB.api, display: 'iframe', caption: Caption Field,
var imageData = context.getImageData(0, 0, canvas.width, canvas.height); var data = imageData.data; and var data
var id = Session[staff_id].ToString() //I have datatable with 5 columns DataTable dt = function_return_Datatable(id);
var mychars = 'abcdefghijklmnopqrstuvwxyz'; for (i = 0; i < mychars.length; i++) { alert(i.toString()
var $page = el.parents('div[data-role=page]:visible'); Being called on pageinit() is showing null for me. Does
var textRange = document.body.createTextRange(); textRange.collapse(true); if( textRange.findText(tex)) { textRange.execCommand(BackColor, false, yellow); } The above

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.