For example in the jQuery documentation I find both JSON and JSONP mentioned. What is the difference exactly? How can I see which is which? Which one should be used for what?
And what does the PHP function json_encode generate?
How can I return an response (lets say an array) to the client with a name assign to it form a python script.
echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}';
in this scenario it returns an array with the name(jsonValidateReturn) assign to it also this can be accessed by jsonValidateReturn[1],so I want to do the same using a python script.
I tried it once but it didn't go well
array_to_js = [vld_id, vld_error, False]
array_to_js[2] = False
jsonValidateReturn = simplejson.dumps(array_to_js)
return HttpResponse(jsonValidateReturn, mimetype='application/json')
Thanks.
I have a page that comes back as an UnexpectedPage in HtmlUnit, the response is JSON. Can I use HTMLUnit to parse this or will I need an additional library?
Hi everyone,
am trying to read a json file to display its contents in my datagrid but i keep getting an empty grid. Can anyone help with a working example.
Thanks in advance.
var responseFromServer = "{\"flag\":true,\"message\":\"\",\"result\":{\"ServicePermission\":true,\"UserGroupPermission\":true}}";
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var responseValue = serializer.DeserializeObject(responseFromServer);
responseFromServer value is get a webservice, and then how to get the json string value, such as "flag","Servicepermission"??
Hey guys,
I have this script working fine with OAuth, but I accidentally nuked my 350 API hits with a stupid while statement :( I'm trying to get data from the Twitter API without OAuth, I can't figure it out (still pretty new), heres what I have
<html>
<body>
<center>
<hr />
<br />
<table border="1">
<tr><td>ScreenName</td><td>Followed back?</td></tr>
<?php
//twitter oauth deets
$consumerKey = 'x';
$consumerSecret = 'x';
$oAuthToken = 'x';
$oAuthSecret = 'x';
// Create Twitter API objsect
require_once("twitteroauth.php");
$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
//get home timeline tweets and it is stored as an array
$youfollow = $oauth->get('http://api.twitter.com/1/friends/ids.json?screen_name=lccountdown');
$i = 0;
//start loop to print our results cutely in a table
while ($i <= 20){
$youfollowid = $youfollow[$i];
$resolve = "http://api.twitter.com/1/friendships/exists.json?user_a=".$youfollow[$i]."&user_b=jwhelton";
$followbacktest = $oauth->get($resolve);
//$homedate= $hometimeline[$i]->created_at;
//$homescreenname = $hometimeline[$i]->user->screen_name;
echo "<tr><td>".$youfollowid."</td><td>".$followbacktest."</td></tr>";
$i++;
}
?>
</table>
</center>
</body>
</html>
Neither of the two Twitter functions require authentication, so how can I get the same results?
Thanks guys,
Dex
See following class:
function availItem(xs, s, m, l, xl) {
this.xs = xs;
this.s = s;
this.m = m;
this.l = l;
this.xl = xl;
}
How can I declare the above class using JSON? I think It should be in following manner but problem is to pass argument.
var availItem = {
xs : xs,
s : s,
m : m,
l : l,
xl : xl
}
I'm working with big blobs of JSON. These blobs change slightly over time and a revision history is kept. I'd really like to be able to do a visual diff on them, but my problem is they're being stored without any formatting at all - everything is on one line, so that makes it a little hard to see what changed.
Is there a good way to programatically format them ala http://jsonformat.com/ or http://jsonformatter.curiousconcept.com/?
Does anyone know of free webservice that returns a list in the form of JSON? I have searched many webservice sites but they all return xml. Geonames.org is not required.
List all that you know of please. thanks.
Hello, I have a web application. On the client side I basically need to get the values of some fields and turn them into JSON and then send them to the server in an AJAX kind of way.(asynchronous)
How would you do that? I also am using jQuery
Does anyone know of a simple javascript library that serializes a form DOM object to JSON? I know jQuery has the serialize method but since I am writing an app for IE mobile, I can't use any of the new fancy libraries, must be oldschool simple javascript, as light as possible.
Cheers
I was wondering if its possible to use a json-based schema-free, document-based database like Mongodb or Couchdb on a symfony project like its used for ruby-on-rails websites? And if yes, how can it be done?
I have an application created with PhoneGap and Backbone. I upload a file as JSon and my server receive data like this :
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...
I'm trying to write the file like this :
File.open("#{Rails.root}/public/images/#{self.id}.jpg", "w+") do |f|
f.write(data)
end
It's not working and I don't know what to do. When I'm trying to open the file I have this message "Not a JPEG file: starts with 0x64 0x61".
Do you have a solution?
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
I'm new to JSON and moving around in it in jQuery. I'm fine until I hit a '[', as in:
"gd$when": [{
"startTime": "2006-11-15",
"endTime": "2006-11-17",
"gd$reminder": [{"minutes": "10"}]
}],
I tried to do a
eventTime = event["gd$when"]["startTime"];
to get to the 'startTime' (Yes, event is the variable for ajax stuff, it's all working fine until I hit the '[')
Thanks for any help.
How do I parse this json with jQuery?
DayEvents : [{"0":"886","event_id":"886","1":"5029","user_id":"5029","2":"Professional","user_type":"Professional", ...
I have an Java class, like Library, that contains many fields. I want do ajax call to server
and in controller's method I want to have partly initialized @RequestBody Library with only
fields, which are present in json object.
Please Help
I am trying to use PHP to make a JSON file. Part of the code is as follow
$array = array("hello", "world");
$string='{"person": [
{
"name":'$array[0];',
"age":'$array[1];'
}
]
}';
The file created. However, $array[0] and $array[1] doesn't return the values "hello" and "world" but as $array[0] and $array[1]
Any idea?
Thanks
I have a game which I deployed for desktop and Android. I can read JSON data and create my levels, but when it comes to reading JSON files from web app, I get an error that logs, "cannot read the json file".
I researched a lot and I found out that I should add my JSON config class to configurations, so I added this line to gameName.gwt.xml, which is in core folder:
<extend-configuration-property name="gdx.reflect.include"
value="com.las.get.level.LevelConfig"/>
But it did not work out. I have no idea where should I place this line or where I should change to make my web app work, so I can read JSON files.
I have a game which I deployed for desktop and android, I can read json data and create my levels, but the problem is, when it comes to reading json files from web app, I get an error that logs, cannot read the json file, I researched a lot and I found out that I should add my json config class to configurations, I added this line to gameName.gwt.xml, which is in core folder
<extend-configuration-property name="gdx.reflect.include" value="com.las.get.level.LevelConfig"/>
but it did not work out too, I have no idea where should I place this line, or where should I change to make my web app work, so I can read json files
Using a jQuery dialog, on clicking OK I call $.post( "save.asp", { id: 1, value: "abcxyz" } ); to pass the values to my ASP classic file that will update the database. I don't need a return value (unless it fails).
I'm a relative noob to jQuery, so I'm assuming I'm using JSON to pass the values to the ASP file. I just don't know what to do with them in ASP (using VBScript). I've seen things like ASP Extreme, but I'm not clear on how to use them. I've tried referencing values via the Request collection, but no luck. All I want to do is take the values passed, parse them out, then save them to the database.
Sorry if this is a duplicate, but this just isn't clicking for me.
I have a column in the a database with values like the below.
[{"noteText":"Today was sunny.","noteDate":"2010-03-30 10:06:22"},{"noteDate":"2010-04-06 13:21:36","noteText":"Today was windy."}]
I think they are from an array of objects serialized via flash to Json.
What I need to do is pull out the noteText and noteDate values only and record them back to the database as a normal string.
I was hoping to just deserialize back to objects and build up a string from there, however,
due to my unfamiliarity with c# and .Net I've hit a brick wall trying to deserialize the string.
var obj = jsonSerializer.DeserializeObject(ns);
Am I going in the right direction or should I be looking at doing some string manipulation?
Any pointers much appreciated.