I'm looking for a simple way to parse JSON, extract a value and write it into a db in Rails.
Explicitly what I'm looking for is a way to extract a shortUrl from the JSON returned from the bit.ly API:
{ "errorCode": 0, "errorMessage": "", "results": { "http://www.foo.com": { "hash": "e5TEd", "shortKeywordUrl": "", "shortUrl": "http://b...
asp.net mvc model object is being fetched by ajax call - $.ajax(....
form has fields with IDs exactly to matching properties on returned json object (created by Html.TextBox("NAME", Model.Order.NAME) )
How to automatically populate fields(inputs) with corresponding json object properties ?
Manually would be like $("#NAME).val(json.NAM...
I have Queryset:
queryset = Status.objects.all()[:10]
Model Status hasn't got field commentAmount so I would add it to every object in Queryset:
for s in queryset:
s.commentAmount = s.getCommentAmount()
All is fine, print s.commentAmount shows good results, but after:
response = HttpResponse()
response['Content-Type'] = "text/j...
Working from the railscast #160 base code I've set up a very simple site that allows me to log in, out and register an account. (Its almost identical except that I've removed the 'username' from the users migrate table and relevant views so only an email address is required)
I'm now trying to create a new log in action so that I can log...
I'm creating a contest sign-up page for our annual math competition at my school. It requires some AJAX like behavior when you click and select an item in a dropdown list.
I've gotten an event to fire when I select something in the dropdown (I'm currently showing an alert box):
<script type="text/javascript">
$(function() {
...
Hi,
I have the piece of code below of a template Ajax enabled WCF service. What can i do to make it return JSon instead of XML?
thanks.
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
[ServiceContract(Namespace = "WCFServiceEight")]
[AspNetCompati...
I'm writing a Google Chrome extension for users to monitor their Stack Overflow account and notify them of new reputation, but I'm having problems with the JSON request to access the rep data. I'm using JQuery as my JSON library.
Using the address: http://stackoverflow.com/users/rep/{userid}/{from-time}/{to-time} where the times are in ...
I have a 2D array which I want to send to a php page with $.ajax.
This is the code which creates the array:
for (var i = 0; i<rowlen; i++) {
if (breakcheck) {
break;
}
for (var j = 0; j<=columnlen; j++) {
...
In my database I store a number of "topics" and "examples". Each example belongs to one topic.
I'd like show all the topics by name ASC in a tree component except for one topic (Topic C) which I always want on top. This may though come to change later and I'd rather not change the basic JSON output of topics and examples from the DB.
1...
I have a .NET MVC controller action that returns a JsonResult to a YUI AsyncRequest callback. All is working fine with the AsyncRequest call and the "Content" model data is successfully updated. How can I now assure that the user is logged before the AsyncRequest is made?
Normally I would use the [Authorize] attribute which returns an e...
I am trying to transmit objects of a particular class from one server to another.
The options I'm looking at are:
Serialize the data as JSON and send
it over the wire using HTTP, and
de-serialize at the other end.
Serialize the data into some binary form and transmit using TCP
sockets.
What are the best practices in this area? Wha...
Hi,
I'm trying to consume an ASP.NET web service, using jQuery's Ajax methods. I want the return type of the web service method to be JSON-formatted data, and I'm marking the method with these attributes:
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public MyObject[] GetMyO...
I have the following code:
jQuery:
$.ajax({
url: '/personcontroller/getperson',
cache: false,
type: "POST",
data: $('#person').serialize(),
success: function(data) {
alert('yay');
}
});
});
Controller:
public ActionResult getPerson(Person person)
{
return new Json(person);
}
Html Form/Spark:
<form id="person">
<i...
Let's say I have a Dictionary<string,object> like so:
var foo = new Dictionary<string, object>();
foo["bar"] = new
{
Quux = "bacon",
Quinge = 42
};
foo["baz"] = DateTime.Now;
I expect it the result to the user would be akin to:
{"bar":{"Quux":"bacon","Quinge":42},"baz":"2009-12-02 17:23:00"}
However, it could just as easily...
I am a little confused about the benefits or conc using scriptmanager with ajax calls or use JQuery to direct call webmethods.
Can some one give me some hints about this issue? when to use which? there is any different while dealing with JSON?
...
I got it working, it's great. One question though: are there any limits on these string parameters?
If so, what are some common ways to deal with these limitations?
Thanks!
...
If I have a list like the following:
<ul class="nameList">
<li value="1">Bob</li>
<li value="2">Frank</li>
<li value="3">Sally</li>
</ul>
How can I convert that into a json object like so:
[{"id":"1","title":"Bob"},
{"id":"2","title":"Frank"},
{"id":"3","title":"Frank"}]
I need to get that data into that format...
Hi guys,
I've read lots of tutorials on how to deserialize a JSON object to an object of a particular using DataContractJsonSerializer. However, I'd like to deserialize my object to a Dictionary consisting of either Strings, Arrays or Dictionaries, such as System.Json does with SilverLight when I say JsonObject.Parse(myJSONstring).
Is ...
I am using REST and OAuth to talk to a Rails app (from an iPhone app, but that should not be relevant). However, I am running into some issues with Rails' CSRF protection (via protects_from_forgery).
I understand that CSRF protection only kicks in for regular form submissions (i.e. Content-Type=application/x-www-form-urlencoded), so I w...
Has anyone way around this bug?
echo json_encode(array('url'=>'/foo/bar'));
{"url":"\/foo\/bar"}
I use Zend_Json and Zend_Json_Expr so I can get even callback functions inside my js object -- but I can't get a url to come out in a usable format!
echo Zend_Json::encode(array(
'url'=>new Zend_Json_Expr('/foo/ba...