1

A Dictionary is generated in Swift and converted to JSON to produce the following:

{"recordId":"1184","category":"Audio","qtyInStock":"1","itemId":"54","itemName":"100.16.4 Snake","make":"LiveWire","plShared":"1","description":"100' 16-channel, 4-return audio","subcategory":"Snake","barcode":"54","showInResults":"1"}

The JSON is then URL encoded and attached to a URL pointing at a PHP file. The encoded JSON is as follows:

%7B%22recordId%22:%221517%22,%22category%22:%22Audio%22,%22qtyInStock%22:%221%22,%22itemId%22:%221698%22,%22itemName%22:%22ADAPT-XLRM%22,%22make%22:%22StudioHub%22,%22plShared%22:%22%22,%22description%22:%22%22,%22subcategory%22:%22Adapter%22,%22barcode%22:%221698%22,%22showInResults%22:%22%22%7D

According to this site, that decodes back into the original JSON. However, when echoing that from the PHP file using the following code where data is the passed param:

$json = $_GET['data'];
echo $json;

The returned JSON looks like this:

{\"recordId\":\"1184\",\"category\":\"Audio\",\"qtyInStock\":\"1\",\"itemId\":\"54\",\"itemName\":\"100.16.4 Snake\",\"make\":\"LiveWire\",\"plShared\":\"1\",\"description\":\"100\' 16-channel, 4-return audio\",\"subcategory\":\"Snake\",\"barcode\":\"54\",\"showInResults\":\"1\"}

What is missing here that would generate this result?

1
  • You should disable PHP magic quotes! Commented Feb 3, 2015 at 7:06

1 Answer 1

2

Try with -

echo stripslashes($json); 
Sign up to request clarification or add additional context in comments.

2 Comments

That has the same result.
'stripslashes' was the fix!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.