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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:07:21+00:00 2026-06-13T21:07:21+00:00

I have a javascript object called blocki that I want to serialize and update

  • 0

I have a javascript object called blocki that I want to serialize and update using a rest API. So I call:

JSON.stringify(blocki)

And that gives me this string:

"{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}"

That is almost what I need, except the doubly quoted string should have single quotes on the outside, like so:

'{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}'

According to examples on MDN JSON.stringify it should return an string wrapped in single quotes. But when I try the same example in that page, I get string wrapped in double quotes. For instance, when I type JSON.stringify({}) in Firefox and chrome console, I get back "{}" instead of '{}'.

How can I properly serialize my Javascript object so the outer quotes are: '. Again, this string is an example of what I want to achieve:

'{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}'

Ideally, I would like to learn an nice way to serialize the object instead of having to modify the string after serialization.

Edit:
The reason I think I need to do this is that the API I am working with is somehow not happy when the string is wrapped in double quotes. For example when I do

curl -i -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d "{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}" 'http://localhost:3000/api/blockies/17'

The request fails and server gives a parsing error. However when I try:

curl -i -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}' 'http://localhost:3000/api/blockies/17'

The put request goes through successfully and the object is updated.

  • 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-13T21:07:22+00:00Added an answer on June 13, 2026 at 9:07 pm

    There are no differences between strings wrapped in single or double quotes, besides escaping which is done automatically by the JSON.stringify method. The single/double quotes which wrap string literals are not part of the string itself.

    Double quotes is the way Firefox and Chrome prefer to represent string literals in the console.


    Edit: Now with the CURL command it changes the meaning of the question completely.

    "{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}"
    

    The string above is not a valid string as you can’t have unescaped double quotes inside a double quote-wrapped string.

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

Sidebar

Related Questions

I have a javascript object called 'element' of type HTMLInputElement that corresponds to a
I have an object model called MyObject that I'm serializing to a json string
Lets say I have a JSON document / JavaScript object that looks like this:
Using JavaScript, say I have a function X, and in that function an object
I have a Javascript object that requires 2 calls out to an external server
I have a Javascript object that basically represents a Row in an .NET GridView.
I have a JavaScript object with thousands of properties and what i want if
I have an included javascript file thats initializes an empty array object called widgets
I have a Javascript object that (very simplified) looks like this if('undefined' !== typeof(listCtrls)){
I'm currently having an issue where I have a javascript object that is trying

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.