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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:06:34+00:00 2026-06-06T00:06:34+00:00

I cannot convert JS object to exact string, my code: jsonObj[‘payment_value’]=100.10; jsonObj[‘payment_date’]=2012-06-15; jsonObjStr =

  • 0

I cannot convert JS object to exact string, my code:

jsonObj['payment_value']=100.10;
jsonObj['payment_date']="2012-06-15";
jsonObjStr = JSON.stringify(jsonObj);
alert(jsonObjStr);
$.post("test", jsonObjStr.toString(), function(output){
    alert(output);
});

first alert displays:

{“payment_date”:”2012-06-15″,”payment_value”:100.1}

and in function test (i’m using codeigniter framework) it should print “payment_date” and “payment_value”, code like this:

echo $this->input->post("payment_value");
echo $this->input->post("payment_date");

which is equvalent in “clear” php to:

echo $_POST["payment_value"];
echo $_POST["payment_date"];

but second alert displays clear string.

If I put

{“payment_date”:”2012-06-15″,”payment_value”:100.1}

instead of jsonObjStr.toString() it works fine

Does anyone knows how to fix it WITHOUT using json_decode? I need to have posted values in this format, not in other array

So i need to convert jsonObjStr exact to string (something inversely to function eval())

Thank in advice

  • 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-06T00:06:35+00:00Added an answer on June 6, 2026 at 12:06 am

    According to $.post docs, second argument should be map or query string:

    map example:

    {
       "payment_date":"2012-06-15",
       "payment_value":100.1
    }
    

    query string example:

    'payment_date=2012-06-15&payment_value=100.1​​​'
    

    When you use JSON.stringify, then you get:

    '{"payment_date":"2012-06-15","payment_value":100.1}'
    

    which is invalid query string. So the solution is: do not stringify anything, pass the object itself as 2nd argument:

    jsonObj['payment_value']=100.10;
    jsonObj['payment_date']="2012-06-15";
    $.post("test", jsonObj, function(output){
       alert(output);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code throws an compile-time error like Cannot convert type 'string' to 'int'
I get an error of Cannot convert object of type System.String' to type 'System.Collections.Generic.List'1[...+ContactHolder]'
if i execute the following code i get a cannot convert to object error;
Error: Cannot convert type 'string' to 'object[*,*]' That's the error I have been getting.
Exception: Cannot convert the value in attribute 'Text' to object of type 'System.String'. Unable
When I run the following code i receive the message cannot convert 'System.Object[]' to
The error is cannot convert object to sql parameter I'm working with a bol->dal,
I tried many things but I always get cannot convert string to membershipuser from
I get an error in the bellow code it says I cannot convert method
Given this code: List<Integer> ints = new ArrayList<Integer>(); // Type mismatch: // cannot convert

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.