Hi, im writting a twitter mashup service. When i receive the json data, some of the twit ids are greater than 2147483647 (which is the maximum allowed integer on 32bit servers).
I came up with a solution that works, which is converting the integers to strings; that way the json_decode() function won't have any problems when trying to ge...
<?php
//example code
$url = 'http://clients1.google.com/complete/search?hl=en&q=speed';
function processURL( $url )
{
$contents = file_get_contents( $url );
return $contents;
}
print_r( processURL($url) );
?>
Output:
window.google.ac.h(["speed",[["speed test","89,300,000 results","0"],["speed channel","76,100,000 results"...
I don't get it, the data produced by json_encode is much more straightforward than serialize and yet both the JSON encode and decode functions are much more slower than the serialize and unserialize counterparts. Why?
...
Hi,
I'm used to PHP, and decoding json data is just a line of code.
What would be the easiest way to do this in java?
...
Hello,
Can anyone help me with this one
I have this query and only after adding the last one wich is indexed against the euro
I get invalid json.
$url = 'http://www.google.com/finance/info?client=ig&q=goog,yhoo,AMS:TOM2';
$response= json_decode($response,true);
The only thing different if I directly echo the output is the quest...
My google Docs Spreadsheet call returns this response in the json format
(I only need everything after "rows")
please look at the formatted response here : )
I use php's json_decode function to parse the data and use it (Yes, I am awful at php) This code returns NULL, and according to the documentation, NULL is returned "if the json can...
Question: The JavaScript code below:
records is JSON serialized data.
I can access it right away from JavaScript by using for example
alert(records.data[0].Phone);
The problem now is that some bright spark used a whitespace in FirstName and LastName, which means I would have to access it like
alert(records.data[0].Last Name); Which...
Does anyone know why this happens?
var_dump(json_decode(stripslashes(json_encode(array("O'Reiley"))))); // array(1) { [0]=> string(8) "O'Reiley" }
var_dump(json_decode(stripslashes(json_encode(array("O\'Reiley"))))); // NULL
Are ' used at all by the JSON functions?
...
I am using jQuery.ajax(...) to retrieve JSON data from an ASP.NET MVC service. When the server encounters an exception, I send a 400 Bad Request status back to the client and send my exception as a JsonResult:
Response.StatusCode = 400;
return Json(new { ex.Message, ex.StackTrace });
And here's my jQuery code:
$.ajax(
{
type: "PO...
I have an app that uses ajax (jQuery) quite extensively and when sending JSON to my web service I always "escape" any strings to make sure there is not any nastiness in there. To decode it at the other end (in my c# code) I have been using HttpUtility.URLDecode() and this has been working a treat until it came to the £ symbol, it just do...
Hi,
one of my PHP script get JSON from an Ajax call. With a depth of 5, all run fine, but if depth is 6, json_decode() fail on Sun box. Under Linux or Windows same scripts and data run fine.
Does anyone have an hint for me?
Thanks, Cédric
...
Hi,
Observe this little script:
$array = array('stuff' => 'things');
print_r($array);
//prints - Array ( [stuff] => things )
$arrayEncoded = json_encode($array);
echo $arrayEncoded . "<br />";
//prints - {"stuff":"things"}
$arrayDecoded = json_decode($arrayEncoded);
print_r($arrayDecoded);
//prints - stdClass Object ( [stuff] => things...
When using PHP's json_decode(), I don't see a way to distinguish between a NULL return value indicating a failure in decoding and a correctly decoded NULL value:
var_dump(json_decode('nonsense')); // returns NULL
var_dump(json_decode(json_encode(NULL))); // also returns NULL
And case one doesn't throw an exception. So I'm not sure how...
Hi there, I'm trying handle bad json data when parsed through json_decode(). I'm using the following script:
if(!json_decode($_POST)) {
echo "bad json data!";
exit;
}
If $_POST equals:
'{ bar: "baz" }'
Then json_decode handles the error fine and spits out "bad json data!";
However, if I set $_POST to something like "invalid dat...
Am trying to validate my form using an AJAX call
$("#button").click(function() {
$.ajax({
type: "POST",
url: "<?php echo $this->baseUrl() ?>/expensetypes/async",
data: 'fs=' + JSON.stringify($('#myform').serialize(true)),
contentType: "application/json; charset=utf...
Hi all,
I am getting data in the Social App in form of JSON. I am using OpenSocial v0.9 Templates to render data in the App with the tag but the problem is I want to render data in tabular form, but with it repeats items in a row so is there any way possible!
Regards,
Abhishek
...
I can create a sparse php array (or map) using the command:
$myarray = array(10=>'hi','test20'=>'howdy');
I want to serialize/deserialize this as JSON. I can serialize it using the command:
$json = json_encode($myarray);
which results in the string {"10":"hi","test20":"howdy"}. However, when I deserialize this and cast it to an arr...
Hi, everybody! Could I ask you to help me to decode this JSON code:
$json = '{"inbox":[{"from":"55512351","date":"29\/03\/2010","time":"21:24:10","utcOffsetSeconds":3600,"recipients":[{"address":"55512351","name":"55512351","deliveryStatus":"notRequested"}],"body":"This is message text."},{"from":"55512351","date":"29\/03\/2010","time":...
Hi, guys!
I know how to decode a JSON string with one object with your help from this example http://stackoverflow.com/questions/2543389/how-to-decode-a-json-string
But now I would like to improve decoding JSON string with several objects and I can't understand how to do it.
Here is an example:
{ "inbox": [
{ "firstName": "Brett", ...
Take the following JSON string (generated by some ExtJS code - but that's irrelevant):
[{"action":"Setting","method":"toggle","data":["welcome-home"],"type":"rpc","tid":2},{"action":"ContentExtFeFillout","method":"todo","data":[true,0,8,false],"type":"rpc","tid":3}]
being sent to a server as a POST request and retrieved via $GLOBALS['...