json

Python: how to make a class serializable

So, that's the question: How to make a class serializable? a simple class: class FileItem: def __init__(self, fname): self.fname = fname What should I do to be able to get output of: json.dumps() without an error (FileItem instance at ... is not JSON serializable) ...

ASP MVC variable to javascript?

I am trying to get the locations of devices per project. I have a page which shows a google map and a list of all devices that belong to a project. My actions are: public ActionResult GoogleMaps(int id) { return View(Project.Find(id).DeviceLocations); } public ActionResult Map(int id) { var map = Project.Find(id).D...

DataContractJsonSerializer with arbitrary key names

Is there a way to convince DataContractJsonSerializer to parse JSON with arbitrary key names? As an example, consider the following JSON emitted from a web service: { "1": { "First":"John", "Last":"Doe" }, "2": { "First":"Jane", "Last":"Doe" } } Obviously, it's easy to get the "inside" objects. I just apply t...

What is the easiest way to parse json using gson when the element to parse is an element of a json string?

I am using gson to parse json into java beans. For the API I am using, a large number of the json results include the result as the first property of a json object. The "gson way" seems to be to create an equivalent wrapper java object, which has one property for the target output type - but this results in unnecessary throwaway classes....

How can I generate XML from the JSON Data using c#?

I have the JSON data something like below: { "#data": [ { "nid": "814", "type": "resource", "language": "", "uid": "125", "status": "1", "title": "title 1", "description": "description 1", "rating": "5", "picture": "" ...

NSString manipulation

I have an NSString which I need to 'clean' before feeding it into my json read however I can't find a way of doing so. This is my NSString: "DUMMY({parameters:{code:"60246", language:"en", country:"en"}, result:{"...JSON...});" Basically I need to remove everything except: {"...JSON...} The problem is the codes etc change? ...

ASP.net MVC - Model with DateTime, trying to serialize for Json() for jqGrid

I've got a model... [DataContract] public class DeviceModel { [DataMember(Order=1)] public string Alias { get; set; } [DataMember(Order = 2)] public string Location { get; set; } [DataMember(Order = 3)] public string State { get; set; } [DataMember(Order = 4)] ...

$.ajax() joining two data objects.

Lets say I want to join two data sets in my $.ajax call as such: updateData: function(dataDetails) { $.ajax({ url: './example.php', data: { lets:"GET", real:"funky" }, type: "POST", dataType: "json", }); } dataDetails in the function argument contains another set...

Authentication on App Engine / Python / Django non-rel over JSON

I'm building a site on Google App Engine, running python and Django non-rel. Everything is working great for HTML and posting/reading data. But as I'm moving forward I'd like to do many of the updates with AJAX, and eventually also over mobile devices like Android and iPhone. My pages use django non-rel and my login/logout authenticatio...

How to get local date with correct timezone (with daylight savings) using only hoursOffset and minutesOffset

I need to a date to the user's timezone. I know the hours and minutes offset of the timezone. So, I have two variables hoursOffset and minutesOffset. I need to figure out the timezone from that, if daylight savings exists right now, and then get the correct local date with javascript. I'm not sure how to check if daylight savings ex...

JSON vs XML Benchmarks? (C#)

Is there any read/write benchmarks comparing JSON and XML for C#? ...

jQuery Ajax call script on success

Hello everyone, This has been driving me nuts for a few days. I am desperate for help. I have 2 files, index.php and test.php, simplied version to follow. index.php <div id="div-hi"></div> <div id="div-bye"></div> <script> $(document).ready(function(){ setInterval(function(){ $( function() { $.ajax( { url : 'test.php', type : 'pos...

rails to_json unexpected behavior for include_root_in_json

Hi - I have a model like this class Parent < ActiveRecord::Base :has_many :kids end class Kid < ActiveRecord::Base :has_many :grandkids :belongs_to :parent end I can generate json like this: the_parent.to_json( :methods => [:kids] ) => { "parent" : { "kids" : [ { "kid" : { "name" => "kid0" .... and so on. Just what I want. ...

Decoding html returned as json response - android

I am getting following encoded html as a json response and has no idea how to decode it to normal html string, which is an achor tag by the way. x3ca hrefx3dx22http:\/\/wordnetweb.princeton.edu\/perl\/webwn?sx3dstrandx22x3ehttp:\/\/wordnetweb.princeton.edu\/perl\/webwn?sx3dstrandx3c\/ax3e I have tried java.net.UrlDecoder.decode withou...

How to create a java class for a JSON string where keys are variable?

The response array ( 0 => array ( 'time_start' => 1252652400, 'time_stop' => 1252911600, 'stats' => array ( 6002306163363 => array ( 'id' => 6002306163363, 'impressions' => '6713', 'clicks' => '7', 'spent' => '593', 'actions' => '1', ...

How would I send an NSArray filled with objects over a HTTP POST?

I have a product/shopping list (consisting of product objects with a name, product_id etc) on the iPhone side. I wish to send this list to the server where I will compare the list on the server with the one from the iphone (to merge the changes made and send the merged list back to the iphone). How would I send my array over a HTTP POST...

Namespaces in JSON

Is there such a thing as JSON namespaces, just like XML namespaces? Has anyone created a spec or libraries for this? Is this a good or a terrible idea? I want to make a data spec that can be represented in XML as well as JSON. However I also need the namespace concept, that the data can be extended by annotations in different vocabulari...

why does json ObjectMapper throw java.io.EOFException: No content to map to Object due to end of input

I have a response from a REST web service that looks like this:- {"number":447919191231,"messages":"","receipt":{"uid":"5d1bddf5-1b98-4a32-8ebf-f71c3973e7a8","messages":"","status":"SUCCESS","code":"09641","ttl":120,"url":"http:\/\/server:8080\/x\/d6985"}} and I am attempting to use the method outlined here in the full data binding ex...

JSON Framework and user input validation

Hi guys, I use JSON framework in my iPhone application to send text user input to server. This data will be stored in DB and displayed on web afterwards. I want to ask what I should be aware of safety-wise. I tried to add to my input different symbols (like ":" , "} and so on) to close/break my JSON but it seems that JSON Framework ...

Example of using datatables jquery plugin with a WCF service

Does anyone know of any samples that use the DataTables jquery plugin with a WCF service? I'm attempting to use a WCF service with the JavaScriptSerializer which unfortunately seems to return dodgy JSON by adding extra backslashes. However the DataTables would seem to provide a way to work around that given that the retrieval of the JS...