Mangled Data

[email protected] (John)
Newsgroups php.general
Message-ID <[email protected]>
PHP 7.2.9

An incoming JSON string is not acted on in this script; just passed
through to the next script. I do the following, where 'trans' is a
JSON string:  (ie result of JavaScript stringify() command) 

if (isset($_POST['trans']))
{
 $ord_jdata = $_POST['trans'];

....

<form method="POST" name="order" id="order" onSubmit="finished()"
action="....>
<input type="hidden" name="trans-1" id="trans-1" value= <?php echo
$ord_jdata ?> >
</form>

When this is submitted the data stored in form.trans-1 is NOT the same
as the data in $ord.jdata, specifically the following component, as
shown by the Firefox devtools | inspector command no longer has the
escape \ before the " character. 

The JSON data contains a string (part of an array) that, when received
is:
... ,\"name\":'"some data is found here\", ... 
but this is stored in the form input field as:
... ,\"some" data="" is="" found="" here=\",

which is not at all the same thing.  Apparently the spaces within the
string are being treated as delimiters for null parameters.  

Experimenting, I can do a valid/correct json_decode on the incoming
data; it just doesn't copy properly.

After reading the JSON part of the PHP manual I can't see why this
should be so and I suspect that I have run over some constarint on
data formatting but I don't see it.

Can anyone help??

Thanks in advance.

John
============
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.