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)
...
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...
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...
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....
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": "" ...
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?
...
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)]
...
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...
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...
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...
Is there any read/write benchmarks comparing JSON and XML for C#?
...
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...
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. ...
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...
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',
...
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...
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...
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...
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 ...
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...