json

Create JSON with .net

First off, let me start off that I am not a .net developer. The reason why I am asking this question is that we rolled out our REST-API and one of our first integration partners is a .net shop. So basically we assumed that .net would provide some sort of wrapper to create JSON, but the developer in question created the string by hand. I...

How to implement custom JSON serialization from ASP.NET web service?

What options are there for serialization when returning instances of custom classes from a WebService? We have some classes with a number of child collection class properties as well as other properties that may or may not be set depending on usage. These objects are returned from an ASP.NET .asmx WebService decorated with the ScriptSe...

How do I reference an object dynamically?

In Javascript, I have an object: obj = { one: "foo", two: "bar" }; Now, I want do do this var a = 'two'; if(confirm('Do you want One')) { a = 'one'; } alert(obj.a); But of course it doesn't work. What would be the correct way of referencing this object dynamically? ...

Deserialize jSON Google AJAX Translation API

I've got the JSON coming back like this: {"responseData": [{"responseData":{"translatedText":"elefante"},"responseDetails":null,"responseStatus":200},{"responseData":{"translatedText":"Burro"},"responseDetails":null,"responseStatus":200}], "responseDetails": null, "responseStatus": 200} And I need to parse it into a ResponseData objec...

Is there a better way to verify if a request accepts JSON?

Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest request) { const string JsonType = "application/json"; if (request.ContentType.ToLower(CultureInfo.InvariantCulture).StartsWith(JsonType)) { return true; } if (request.AcceptTypes.Select(t => t.ToLower(CultureInfo.In...

Proper way to deal with variations in JSON serialization

I have a web service that uses Python's SimpleJSON to serialize JSON, and a javascript/ client that uses Google's Visualization API. When I try to read in the JSON response using Google Data Table's Query method, I am getting a "invalid label" error. I noticed that Google spreadsheet outputs JSON without quotes around the object keys. ...

Groovy parsing JSON vs XML

Using groovy, would you expect better performance in terms of speed and memory overhead to read and query JSON vs XML? ...

Object Initializer syntax to produce correct Json

I am attempting to use linq to shape list of data into a particular shape to be returned as Json from an ajax call. Given this data: var data = new List<string>(); data.Add("One"); data.Add("Two"); data.Add("Three"); And this code: ** Which is not correct and is what needs to be fixed!! ** var shap...

How to JSON decode array elements in JavaScript?

I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be. But if I try to do a redirect or simply do an 'alert' on the link array element I get: function(){return JSON.encode(this);} As far as...

How do I Update a GridView from a Page Method from code behind?

How do I update a Gridview on a aspx page from a webmethod? Here is my code. [WebMethod] public static string GetDate() { return DateTime.Now.ToString(); } I can't use the "findcontrol" or the "this" methods so I need some help. ...

Is there a library to read JSON in C# on Windows Mobile?

Hi, I am trying to find a library to parse JSON on C# on Windows Mobile (working with Visual Studio 2005). The libraries that I have found that allow me to parse JSON in C# (litjson and Jayrock) don't work on Windows Mobile, they require classes that are not present in the .NET compact framework. Is there any library that I have overloo...

Does the Microsoft JSON object serialization differ from the "normal" serialization?

I recall hearing that the way Microsoft had to implement the JSON serialization for their AJAX framework was different than most other libraries out there. Is this true? And, if so, how is it different? ...

How to use JSON to create object that Inherits from Object Type?

I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type. Here's an example of an Object and creating an instance of it: Person = function() { }; Person.prototype = { FirstName: null, GetFirstName: function() { return this.FirstName; ...

REST / SOAP endpoints for a WCF service

Hi, I have a WCF service and I want to expose it as both a RESTfull service and as a SOAP service. Anyone has done something like this before? ...

Are there any JSON (or YAML) based "time sheet" or "work log" related formats for recording time spent on tasks?

I just need a simple JSON or YAML (or other) text based format for recording the time I spend on tasks. I prefer to do as much work as possible in my text editor (e text editor) so it is more natural to me to stay in the editor and not switch back and forth to programs like Excel (plus this way I retain portable and "open" data). The ...

How To Get Photo IDs from Flickr API?

I am trying to use JQUERY to grab photos from a Flickr group. I can get back valid JSON, but can't figure out how to get access to the actual photos. The JSON that is returned contains an empty list where I would expect photos. So when I plug this into the browser: http://api.flickr.com/services/rest?method=flickr.groups.pools.getPhoto...

Converting XML to JSON using Python?

I've seen a fair share of ungainly XML->JSON code on the web, and having interacted with Stack's users for a bit, I'm convinced that this crowd can help more than the first few pages of Google results can. So, we're parsing a weather feed, and we need to populate weather widgets on a multitude of web sites. We're looking now into Pytho...

Serializing to JSON in jQuery

I know how to serialize an object to JSON in ASP.NET Ajax, but I'm trying to do things on the client in a less Microsoft-specific way. I'm using jQuery. Is there a "standard" way to do this? My specific situation: I have an array defined something like this: var countries = new Array(); countries[0] = 'ga'; countries[1] = 'cd'; ... a...

Creating a sortable tree/grid in Javascript

I'd like to create a tree structure from JSON, but with multiple columns that can be sorted. I've seen lots of implementations of trees and grids but never one mixed. Does anyone know of a plugin or feature for any Javascript toolkit that can make this happen so I don't have to re-invent the wheel here? ...

How do you make php's json_decode compatible with firefox's javascript?

it appears if you have something like var my_var = {"foo" : "bar"}; in javascript (with firefox at least) and post it to a php server you will receive a string like {foo:"bar",} on the server side. But json_decode in php doesn't like the trailing ',' or the lack or quotes around 'foo'. Is there a nice way to clean up the received...