json

Can you Instantiate an Object Instance from JSON in .NET?

Since Object Initializers are very similar to JSON, and now there are Anonymous Types in .NET. It would be cool to be able to take a string, such as JSON, and create an Anonymous Object that represents the JSON string. Use Object Initializers to create an Anonymous Type: var person = new { FirstName = "Chris", LastName = "Johns...

Can you use a trailing comma in a JSON object?

When manually generating a JSON object or array, it's often easier to leave a trailing comma on the last item in the object or array. For example, code to output from an array of strings might look like (in a C++ like pseudocode): s.append("["); for (i = 0; i < 5; ++i) { s.appendF("\"%d\",", i); } s.append("]"); giving you a stri...

using a named function as the callback for $.getJSON in jQuery to satisfy Facebook request signing demands

I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing the request url on the server side (in order to keep my app secret secret). I'm then sending the url over to the browser to be request using jQuery.getJSON(). Facebook requires that I send a copy of all of my request params hashed with my a...

How to format JSON Date?

I'm taking my first crack at AJAX with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON that is returned for Date data types. Basically, I'm getting a string back that looks like this: /Date(1224043200000)/ From a total newbie at JSON - How do I format this to a short date format? Should this be hand...

Replacement for XML to represent Data structures in C++

At work we have a testing tool that is used to send queries to a data source. The tool takes in input as XML files. The XML files were simple and easy to parse as long as the data structures we tried to represent were one layer deep. But now these data structures are more complex and representing them in XML is getting to be highly confu...

Best practices for getting cross-site JSON responses to POST?

I'm working on an intranet with several subdomains. I have control over each subdomain, so security of cross-site requests is not a concern. I have PHP scripts with JSON responses I'd like to call from multiple subdomains without duplication. For GET requests, I can do this with AJAX and JSONP, but that doesn't work with POST requests. S...

How to list the properties of a javascript object

Say I create an object thus: var myJSONObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}; What is the best way to retrieve a list of the property names? i.e. I would like to end up with some variable 'keys' such that: keys == ["ircEvent", "method", "regex"] Thanks. ...

What is the accepted way to send 64-bit values over JSON?

Some of my data are 64-bit integers. I would like to send these to a JavaScript program running on a page. However, as far as I can tell, integers in most JavaScript implementations are 32-bit signed quantities. My two options seem to be: Send the values as strings Send the values as 64-bit floating point numbers Option (1) isn't p...

Filtering JSON Data on the Browser/Client

Here's the scenario-- you've got a JSON object on the browser, and let's say it has a boolean property, called "Active". We want to create a new JSON object that contains only items that have Active = True. Is there an easy way to do this, other than looping through the entire JSON object? I'm basically trying to use ASP.Net AJAX Templa...

How to let an ASMX file output JSON

I created an ASMX file with a code behind file. It's working fine, but it is outputting XML. However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is: [System.Web.Script.Services.ScriptService] public class _default : System.Web.Services.WebService { [WebMethod] [ScriptMethod(U...

JSON call + .net works in debug mode on inbuilt web server but not by going to virtual dir directly

I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: { email: strEmail, message: strMessage }, success: function(result) { //alert('here'); alert(result.message); }, error: function(error) { ...

Which Javascript Ajax Framework is most powerful and very lightweight?

I’ve been using a jQuery to do the whole ajax magic in my web based applications. But I came to a decision that I don’t need all these amazing features jQuery has, except its ajax functions (like $.ajax(), $.get(), $.post, getJSON() and load();). Can you recommend a lightweight crossbrowser ajax library/framework (upto ~10 kb)? Thanks ...

JSON RPC: java method never called, any ideas?

Hi all, I'm trying to get some code working that a previous developer has written. Yep, his now left the company. :-( I have a JSON RPC call being made from the JS code. The JS all runs fine & the callback method gets an object back (not an error object). But the method on the Java class never gets hit. The smd method does get hit tho...

Best AJAX TreeView

What are some of the better AJAX Treeviews out there that support asynchronous JSON loading. YUI TreeView seems nice, but bloated with tables, etc. ...

ASP.NET MVC controller actions that return JSON or partial html

I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously? ...

Does JSON.js cause conflicts with Sys.Serialization.JavaScriptSerializer.serialize

I am using Telerik controls in my webforms and want to serialize object on the client. Since I am getting a stackoverflow error with Sys.Serialization.JavaScriptSerializer.deserialize I wanted to try JSON. With both JSON and and the MS library I get "Sys.Application is undefined." Has anyone encountered this what did you do as a work ...

Converting XML-RPC to JSON in JavaScript

Can anyone recommend a lightweight JavaScript XML-RPC library? After researching this a while ago, I couldn't find anything I was comfortable with, so I kinda ended up writing my own. However, maybe that was stupid, as there must be something suitable out there!? My own pseudo-library is mainly missing a way to turn an XML-RPC response...

Dynamic Associative Array Creation in Javascript from JSON

It sounds a lot more complicated than it really is. So in Perl, you can do something like this: foreach my $var (@vars) { $hash_table{$var->{'id'}} = $var->{'data'}; } I have a JSON object and I want to do the same thing, but with a javascript associative array in jQuery. I've tried the following: hash_table = new Array(); $.eac...

Problem with Ajax.Request using JSon and Prototype

I am using the following function to load a PlayList of Songs from 'PlayListJSON.aspx' but somethings seems wrong,evrytime OnFailure is getting called, I am unable to debug it further. any help would be really gr8. Player.prototype.loadPlaylist = function (playlistId, play) { req = new Ajax.Request('/PlaylistJSON.aspx?id='...

How can you create an ASP.Net 2.0 web service that consumes and produces JSON objects?

I would like create a web service in ASP.Net 2.0 that will supports JSON. Is there a way to do this without WCF and .Net 3.5? Can anyone point me to a good article or sample code? Clarification I need direction on what is the best method, using the .Net 2.0 framework, to communicate JSON objects to a client. Is it possible to do t...