Search Results

Search found 5623 results on 225 pages for 'mr json'.

Page 10/225 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Best and simple way to handle JSON in Django

    - by primal
    Hi, As part of the application we are developing (with android client and Django server) a json object which contains user name and pass word is sent to server from android client as follows HttpPost post = new HttpPost(URL); /*Adding key value pairs */ json.put("username", un); json.put("password", pwd); StringEntity se = new StringEntity(json.toString()); post.setEntity(se); response = client.execute(post); The response is parsed like this result = responsetoString(response.getEntity().getContent()); //Converts response to String jObject = new JSONObject(result); JSONObject post = jObject.getJSONObject("post"); username = post.getString("username"); message = post.getString("message"); Hope upto this everything is fine. The problem comes when parsing or sending JSON responses in Django server. Whats the best way to do this? We tried using SimpleJSON and it turned out not to be so simple as we didn't find any good tutorials or sample code for the same? Are there any python functions similiar to get,put and opt in java for JSON? Any help would be much appreciated..

    Read the article

  • No JSON object could be decoded - RPC POST call

    - by user1307067
    var body = JSON.stringify(params); // Create an XMLHttpRequest 'POST' request w/ an optional callback handler req.open('POST', '/rpc', async); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", body.length); req.setRequestHeader("Connection", "close"); if (async) { req.onreadystatechange = function() { if(req.readyState == 4 && req.status == 200) { var response = null; try { response = JSON.parse(req.responseText); } catch (e) { response = req.responseText; } callback(response); } }; } // Make the actual request req.send(body); ---- on the server side ---- class RPCHandler(BaseHandler): '''@user_required''' def post(self): RPCmethods = ("UpdateScenario", "DeleteScenario") logging.info(u'body ' + self.request.body) args = simplejson.loads(self.request.body) ---- Get the following error on the server logs body %5B%22UpdateScenario%22%2C%22c%22%2C%224.5%22%2C%2230frm%22%2C%22Refinance%22%2C%22100000%22%2C%22740%22%2C%2294538%22%2C%2250000%22%2C%22owner%22%2C%22sfr%22%2C%22Fremont%22%2C%22CA%22%5D= No JSON object could be decoded: line 1 column 0 (char 0): Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in call handler.post(*groups) File "/base/data/home/apps/s~mortgageratealert-staging/1.357912751535215625/main.py", line 418, in post args = json.loads(self.request.body) File "/base/python_runtime/python_lib/versions/1/simplejson/init.py", line 388, in loads return _default_decoder.decode(s) File "/base/python_runtime/python_lib/versions/1/simplejson/decoder.py", line 402, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/base/python_runtime/python_lib/versions/1/simplejson/decoder.py", line 420, in raw_decode raise JSONDecodeError("No JSON object could be decoded", s, idx) JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0) --- firebug shows the following --- Parameters application/x-www-form-urlencoded ["UpdateScenario","c","4.... Source ["UpdateScenario","c","4.5","30frm","Refinance","100000","740","94538","50000","owner","sfr","Fremont","CA"] Based on the firebug report and also the logs shows self.request.body as anticipated. However simplejson load doesn't like it. Please help!

    Read the article

  • unable to get values from JSON converted from XML

    - by Dkong
    I have passed some JSON to my page via a webservice. I used JSON.NET to convert XML to JSON. The JSON output looks ok to me, but I am unable to access some of the items in the response. I am not sure why it is not working. I am using jQuery to read the response and make the webservice call. Even when I try to read the length of the array it says 'undefined' function GetFeed(){ document.getElementById("marq").innerHTML = ''; $.ajax({ type: "POST", url: "ticker.asmx/GetStockTicker", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; for (var i = 0; i < obj.length; i++) { $('#marq').html(obj[i].person); } } }); } This is a copy and paste of my response as it appeared in firebug: {"d":"{\"?xml\":{\"@version\":\"1.0\",\"@standalone\":\"no\"},\"root\":{\"person\":[{\"@id\":\"1\",\"name\":\"Alan\",\"url\":\"http://www.google.com\"},{\"@id\":\"2\",\"name\":\"Louis\",\"url\":\"http://www.yahoo.com\"}]}}"}

    Read the article

  • Weird character at start of json content type

    - by Nek
    Hi, I'm trying to return json content read from MySQL server. This is supposed to be easy but, there is a 'weird' character that keeps appearing at start of the content. I have two pages for returning content: kcb433.sytes.net/as/test.php?json=true&limit=6&input=d this test.php is from a script written by Timothy Groves, which converts an array to json output http://kcb433.sytes.net/k.php?k=4 this one is supposed to do the same I tried to validate it here jsonformatter.curiousconcept.com but just page 1 gets validated, page 2 says that it does not contain JSON data. If accessed directly both pages has no problems. Then what is the difference, why both don't get validated? Then I found this page jsonformat.com and tried the same thing. Page 1 was ok and page 2 wasn't but, surprisingly the data could be read. At a glance, {"a":"b"} may look good but there is a character in front. According to a hex editor online, this is the value of the string above (instead of 9 values, there are 10): -- 7B 22 61 22 3A 22 62 22 7D The code to echo json in page 2 is: header("Content-Type: application/json"); echo "{\"a\":\"b\"}";

    Read the article

  • Append json data to html class name

    - by user2898514
    I have a problem with my json code. I want to append each json value comes from a key to be appended to an html class name which matches the key of json data. here's my Live demo if you see the result in the life demo. it's only appending the last record. is it possible to make it show all records in order? json var json = '[{"castle":"big","commercial":"large","common":"sergio","cultural":"2009"},' + '{"castle":"big2","commercial":"large2","common":"sergio2","cultural":"20092"}]'; html <div class="castle"></div> <div class="commercial"></div> <div class="common"></div> <div class="cultural"></div> javascript var data = $.parseJSON(json); $.each(data, function(l,v) { $.each(v, function(k,o) { $('.'+k).attr('id', k+o); console.log($('#'+k+o).attr('id')); $('#'+k+o).text(o); }); }); for more illustration... I want the result in the live demo to look like this big large sergio 2009, big2 large2 sergio2 20092

    Read the article

  • JSON parse data in javascript from php

    - by Stefania
    I'm trying to retrieve data in a javascript file from a php file using json. $items = array(); while($r = mysql_fetch_array($result)) { $rows = array( "id_locale" => $r['id_locale'], "latitudine" => $r['lat'], "longitudine" => $r['lng'] ); array_push($items, array("item" => $rows)); } ECHO json_encode($items); and in the javascript file I try to recover the data using an ajax call: $.ajax({ type:"POST", url:"Locali.php", success:function(data){ alert("1"); //var obj = jQuery.parseJSON(idata); var json = JSON.parse(data); alert("2"); for (var i=0; i<json.length; i++) { point = new google.maps.LatLng(json[i].item.latitudine,json[i].item.longitudine); alert(point); } } }) The first alert is printed, the latter does not, it gives me error: Unexpected token <.... but I do not understand what it is. Anyone have any idea where am I wrong? I also tried to recover the data with jquery but with no positive results.

    Read the article

  • asmx web service returning xml instead of json in .net 4.0

    - by Baldy
    i have just upgraded a test copy of my site to asp.net 4.0 and have noticed a strange issue that only arises when i upload the site to my server. the site has an asmx web service that returns json, yet when i run the site on my server it returns xml. it as been working fine in asp.net 3.5 for over a year. the webMethod is decorated with the correct attributes... [WebMethod][ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List<LocationRecentChange> RecentChanges() and on my local machine it returns json. yet on the server (Windows 2008 64bit) it returns xml. you can inspect the response on the test site here... my test site using firebug console you will see a 200 OK response and a bunch of XML, and on my local machine the data returned is the JSON i expect. Here is the javascript that calls the service.. function loadRecentData() { $.ajax({ type: "POST", url: "service/spots.asmx/RecentChanges", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: loadRecentUpdates, failure: function(msg) { //alert(msg); } }); } Any suggestions welcome, this has got me stumped!

    Read the article

  • IE7 not digesting JSON: "parse error" [resolved]

    - by Kenny Leu
    While trying to GET a JSON, my callback function is NOT firing. $.ajax({ type:"GET", dataType:'json', url: myLocalURL, data: myData, success: function(returned_data){alert('success');} }); The strangest part of this is that my JSON(s) validates on JSONlint this ONLY fails on IE7...it works in Safari, Chrome, and all versions of Firefox, (EDIT: and even in IE8). If I use 'error', then it reports "parseError"...even though it validates! Is there anything that I'm missing? Does IE7 not process certain characters, data structures (my data doesn't have anything non-alphanumeric, but it DOES have nested JSONs)? I have used tons of other AJAX calls that all work (even in IE7), but with the exception of THIS call. An example data return (EDIT: This is a structurally-complete example, meaning it is only missing a few second-tier fields, but follows this exact hierarchy)here is: {"question":{ "question_id":"19", "question_text":"testing", "other_crap":"none" }, "timestamp":{ "response":"answer", "response_text":"the text here" } } I am completely at a loss. Hopefully someone has some insight into what's going on...thank you! EDIT Here's a copy of the SIMPLEST case of dummy data that I'm using...it still doesn't work in IE7. { "question":{ "question_id":"20", "question_text":"testing :", "adverse_party":"none", "juris":"California", "recipients":"Carl Chan" } } EDIT 2 I am starting to doubt that it is a JSON issue...but I have NO idea what else it could be. Here are some other resources that I've found that could be the cause, but they don't seem to work either: http://firelitdesign.blogspot.com/2009/07/jquerys-getjson.html (Django uses Unicode by default, so I don't think this is causing it) Anybody have any other ideas? ANSWER I finally managed to figure it out...mostly via tedious trial-and-error. I want to thank everyone for their suggestions...as soon as I have 15 rep, I'll upvote you, I promise. :) There was basically no way that you guys could have figured it out, because the issue turned out to be a strange bug between IE7 and Django (my research didn't bring up any similar issues). We were basically using Django template language to generate our JSON...and in the midst of this particular JSON, we were using custom template tags: {% load customfilter %} { "question":{ "question_id":"{{question.id}}", "question_text":"{{question.question_text|customfilterhere}}" } } As soon as I deleted anything related to the customfilter, IE7 was able to parse the JSON perfectly! We still don't have a workaround yet, but at least we now know what's causing it. Has anyone seen any similar issues? Once again, thank you everyone for your contributions.

    Read the article

  • reading Twitter API with JSON framework

    - by iPixFolio
    Hi, I'm building a twitter reader into an app. I'm using this JSON library to parse the twitter API. I'm seeing some odd results on certain messages. I know that the Twitter API returns results in UTF8 format. I'm wondering if I'm doing something wrong when reading the JSON parsed fields. My code is spread out across multiple classes so it's hard to give a concise code drop with the symptoms, but here's what I've got: I am using ASIHTTP for async HTTP processing. Here is processing a response from ASIHTTP: ... NSMutableString* tempString = [[NSMutableString alloc] initWithString:[request responseString]]; NSError *error; SBJSON *json = [[SBJSON alloc] init]; id JSONresponse = [json objectWithString:tempString error:&error]; [tempString release]; [json release]; if (JSONresponse) { self.response = JSONresponse; ... self.response holds the JSON representation of the result from the Twitter call. Now, I will take the JSON response and write each tweet into a container object (Tweet). in the following code, the response from above is referenced as request.response: ... // save list of albums to local cache for (NSDictionary* response in request.response) { Tweet* tweet = [[Tweet alloc] init]; tweet.text = [response objectForKey:@"text"]; tweet.id = [response objectForKey:@"id"]; tweet.created = [response objectForKey:@"created_at"]; [Tweet addTweet:tweet]; [tweet release]; } ... at this point, I have a container holding the tweets. I'm only keeping 3 fields from the tweet: "id", "text", and "created_at". the "text" field is the problem field. To display the tweets, I build an HTML page from the container of tweets, like this: ... Tweet* tweet = nil; for (int i = 0; i < [Tweet tweetCount]; i++) { tweet = [Tweet tweetAtIndex:i]; [html appendString:@"<div class='tweet'>"]; [html appendFormat:@"<div class='tweet-date'>%@</div>", tweet.created ]; [html appendFormat:@"<div class='tweet-text'>%@</div>", tweet.text ]; [html appendString:@"</div>"]; } ... In another routine, I save the HTML page to a temp file. if (html && [html length] > 0 ) { NSString* uniqueString = [[NSProcessInfo processInfo] globallyUniqueString]; NSString* filename = [NSString stringWithFormat:@"%@.html", uniqueString ]; filename = [tempDir stringByAppendingPathComponent:filename]; NSError* error = nil; [html writeToFile:filename atomically:NO encoding:NSUTF8StringEncoding error:&error]; ... I then create a URLRequest from the file and load it into an UIWebview: NSURL* url = [NSURL fileURLWithPath:filename]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:request]; ... At this point, I can see the tweets in a browser window. some of the tweets will show invalid characters like this: iPhone 4 ad spoofed with Glee’s Jane Lynch ... Glee’s should be Glee's Can anybody shed any light on what I'm doing wrong and offer suggestions on how to fix? basically, to summarize: I'm reading a UTF8 feed with JSON I write the UTF8 strings into an HTML file I display the HTML file with UIWebview. some of the UTF8 strings are not properly decoded. I need to know where to decode them and how to do it. thanks! Mark

    Read the article

  • how to user ajax with json in ruby on rails

    - by fenec
    I am implemeting a facebook application in rails using facebooker plugin, therefore it is very important to use this architecture if i want to update multiple DOM in my page. if my code works in a regular rails application it would work in my facebook application. i am trying to use ajax to let the user know that the comment was sent, and update the comments bloc. migration: class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.string :body t.timestamps end end def self.down drop_table :comments end end controller: class CommentsController < ApplicationController def index @comments=Comment.all end def create @comment=Comment.create(params[:comment]) if request.xhr? @comments=Comment.all render :json=>{:ids_to_update=>[:all_comments,:form_message], :all_comments=>render_to_string(:partial=>"comments" ), :form_message=>"Your comment has been added." } else redirect_to comments_url end end end view: <script> function update_count(str,message_id) { len=str.length; if (len < 200) { $(message_id).innerHTML="<span style='color: green'>"+ (200-len)+" remaining</span>"; } else { $(message_id).innerHTML="<span style='color: red'>"+ "Comment too long. Only 200 characters allowed.</span>"; } } function update_multiple(json) { for( var i=0; i<json["ids_to_update"].length; i++ ) { id=json["ids_to_update"][i]; $(id).innerHTML=json[id]; } } </script> <div id="all_comments" > <%= render :partial=>"comments/comments" %> </div> Talk some trash: <br /> <% remote_form_for Comment.new, :url=>comments_url, :success=>"update_multiple(request)" do |f|%> <%= f.text_area :body, :onchange=>"update_count(this.getValue(),'remaining');" , :onkeyup=>"update_count(this.getValue(),'remaining');" %> <br /> <%= f.submit 'Post'%> <% end %> <p id="remaining" >&nbsp;</p> <p id="form_message" >&nbsp;</p> <br><br> <br> if i try to do alert(json) in the first line of the update_multiple function , i got an [object Object]. if i try to do alert(json["ids_to_update"][0]) in the first line of the update_multiple function , there is no dialog box displayed. however the comment got saved but nothing is updated. questions: 1.how can javascript and rails know that i am dealing with json objects? 2.how can i debug this problem? 3.how can i get it to work?

    Read the article

  • Convert JSON to HashMap using Gson in Java

    - by mridang
    Hi, I'm requesting data from a server which returns data in the JSON format. Casting a HashMap into JSON when making the request wasn't hard at all but the other way seems to be a little tricky. The JSON response looks like this: { "header" : { "alerts" : [ { "AlertID" : "2", "TSExpires" : null, "Target" : "1", "Text" : "woot", "Type" : "1" }, { "AlertID" : "3", "TSExpires" : null, "Target" : "1", "Text" : "woot", "Type" : "1" } ], "session" : "0bc8d0835f93ac3ebbf11560b2c5be9a" }, "result" : "4be26bc400d3c" } What way would be easiest to access this data? I'm using the GSON module. Cheers.

    Read the article

  • Send large JSON data to WCF Rest Service

    - by Christo Fur
    Hi I have a client web page that is sending a large json object to a proxy service on the same domain as the web page. The proxy (an ashx handler) then forwards the request to a WCF Rest Service. Using a WebClient object (standard .net object for making a http request) The JSON successfully arrives at the proxy via a jQuery POST on the client webpage. However, when the proxy forwards this to the WCF service I get a Bad Request - Error 400 This doesn't happen when the size of the json data is small The WCF service contract looks like this [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [OperationContract] CarConfiguration CreateConfiguration(CarConfiguration configuration); And the DataContract like this [DataContract(Namespace = "")] public class CarConfiguration { [DataMember(Order = 1)] public int CarConfigurationId { get; set; } [DataMember(Order = 2)] public int UserId { get; set; } [DataMember(Order = 3)] public string Model { get; set; } [DataMember(Order = 4)] public string Colour { get; set; } [DataMember(Order = 5)] public string Trim { get; set; } [DataMember(Order = 6)] public string ThumbnailByteData { get; set; } [DataMember(Order = 6)] public string Wheel { get; set; } [DataMember(Order = 7)] public DateTime Date { get; set; } [DataMember(Order = 8)] public List<string> Accessories { get; set; } [DataMember(Order = 9)] public string Vehicle { get; set; } [DataMember(Order = 10)] public Decimal Price { get; set; } } When the ThumbnailByteData field is small, all is OK. When it is large I get the 400 error What are my options here? I've tried increasing the MaxBytesRecived config setting but that is not enough Any ideas?

    Read the article

  • JSON Feed Returning null while using jQuery getJSON

    - by Oscar Godson
    http://portlandonline.com/shared/cfm/json.cfm?c=27321 It's returning null. I don't really have access to this. I have to have a server admin update the feed to my liking, so if you can tell me how to get this to work as is, without adding tags to my HTML please let me know. I will be using this with jQuery, and ive been trying to use getJSON which is what returns null. $.getJSON('http://portlandonline.com/shared/cfm/json.cfm?c=27321',function(json){ alert(json); }); that returns null. But if i use a flickr feed for example, it works fine. it returns what it should, [onject Object]. Any ideas?

    Read the article

  • Blackberry JDE JSON parsing?

    - by nwalker85
    Every tutorial I can find for parsing JSON with J2ME or Blackberry JDE points to this library: http://www.json.org/java/org.json.me.zip However, this is a dead link. And the googling, it does nothing. Can someone point me in the right direction?

    Read the article

  • Generate JSON object with transactionReceipt

    - by Carlos
    Hi, I've been the past days trying to test my first in-app purchse iphone application. Unfortunately I can't find the way to talk to iTunes server to verify the transactionReceipt. Because it's my first try with this technology I chose to verify the receipt directly from the iPhone instead using server support. But after trying to send the POST request with a JSON onbject created using the JSON api from google code, itunes always returns a strange response (instead the "status = 0" string I wait for). Here's the code that I use to verify the receipt: - (void)recordTransaction:(SKPaymentTransaction *)transaction { NSString *receiptStr = [[NSString alloc] initWithData:transaction.transactionReceipt encoding:NSUTF8StringEncoding]; NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"algo mas",@"receipt-data",nil]; NSString *jsonString = [jsonDictionary JSONRepresentation]; NSLog(@"string to send: %@",jsonString); NSLog(@"JSON Created"); urlData = [[NSMutableData data] retain]; //NSURL *sandboxStoreURL = [[NSURL alloc] initWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"]]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; NSLog(@"will create connection"); [[NSURLConnection alloc] initWithRequest:request delegate:self]; } maybe I'm forgetting something in the request's headers but I think that the problem is in the method I use to create the JSON object. HEre's how the JSON object looks like before I add it to the HTTPBody : string to send: {"receipt-data":"{\n\t\"signature\" = \"AUYMbhY ........... D0gIjEuMCI7Cn0=\";\n\t\"pod\" = \"100\";\n\t\"signing-status\" = \"0\";\n}"} The responses I've got: complete response { exception = "java.lang.IllegalArgumentException: Property list parsing failed while attempting to read unquoted string. No allowable characters were found. At line number: 1, column: 0."; status = 21002; } Thanks a lot for your guidance.

    Read the article

  • Core Data - JSON (TouchJSON) on iPhone

    - by Urizen
    I have the following code which seems to go on indefinitely until the app crashes. It seems to happen with the recursion in the datastructureFromManagedObject method. I suspect that this method: 1) looks at the first managed object and follows any relationship property recursively. 2) examines the object at the other end of the relationship found at point 1 and repeats the process. Is it possible that if managed object A has a to-many relationship with object B and that relationship is two-way (i.e an inverse to-one relationship to A from B - e.g. one department has many employees but each employee has only one department) that the following code gets stuck in infinite recursion as it follows the to-one relationship from object B back to object A and so on. If so, can anyone provide a fix for this so that I can get my whole object graph of managed objects converted to JSON. #import "JSONUtils.h" @implementation JSONUtils - (NSDictionary*)dataStructureFromManagedObject:(NSManagedObject *)managedObject { NSDictionary *attributesByName = [[managedObject entity] attributesByName]; NSDictionary *relationshipsByName = [[managedObject entity] relationshipsByName]; //getting the values correspoinding to the attributes collected in attributesByName NSMutableDictionary *valuesDictionary = [[managedObject dictionaryWithValuesForKeys:[attributesByName allKeys]] mutableCopy]; //sets the name for the entity being encoded to JSON [valuesDictionary setObject:[[managedObject entity] name] forKey:@"ManagedObjectName"]; NSLog(@"+++++++++++++++++> before the for loop"); //looks at each relationship for the given managed object for (NSString *relationshipName in [relationshipsByName allKeys]) { NSLog(@"The relationship name = %@",relationshipName); NSRelationshipDescription *description = [relationshipsByName objectForKey:relationshipName]; if (![description isToMany]) { NSLog(@"The relationship is NOT TO MANY!"); [valuesDictionary setObject:[self dataStructureFromManagedObject:[managedObject valueForKey:relationshipName]] forKey:relationshipName]; continue; } NSSet *relationshipObjects = [managedObject valueForKey:relationshipName]; NSMutableArray *relationshipArray = [[NSMutableArray alloc] init]; for (NSManagedObject *relationshipObject in relationshipObjects) { [relationshipArray addObject:[self dataStructureFromManagedObject:relationshipObject]]; } [valuesDictionary setObject:relationshipArray forKey:relationshipName]; } return [valuesDictionary autorelease]; } - (NSArray*)dataStructuresFromManagedObjects:(NSArray*)managedObjects { NSMutableArray *dataArray = [[NSArray alloc] init]; for (NSManagedObject *managedObject in managedObjects) { [dataArray addObject:[self dataStructureFromManagedObject:managedObject]]; } return [dataArray autorelease]; } //method to call for obtaining JSON structure - i.e. public interface to this class - (NSString*)jsonStructureFromManagedObjects:(NSArray*)managedObjects { NSLog(@"-------------> just before running the recursive method"); NSArray *objectsArray = [self dataStructuresFromManagedObjects:managedObjects]; NSLog(@"-------------> just before running the serialiser"); NSString *jsonString = [[CJSONSerializer serializer] serializeArray:objectsArray]; return jsonString; } - (NSManagedObject*)managedObjectFromStructure:(NSDictionary*)structureDictionary withManagedObjectContext:(NSManagedObjectContext*)moc { NSString *objectName = [structureDictionary objectForKey:@"ManagedObjectName"]; NSManagedObject *managedObject = [NSEntityDescription insertNewObjectForEntityForName:objectName inManagedObjectContext:moc]; [managedObject setValuesForKeysWithDictionary:structureDictionary]; for (NSString *relationshipName in [[[managedObject entity] relationshipsByName] allKeys]) { NSRelationshipDescription *description = [[[managedObject entity]relationshipsByName] objectForKey:relationshipName]; if (![description isToMany]) { NSDictionary *childStructureDictionary = [structureDictionary objectForKey:relationshipName]; NSManagedObject *childObject = [self managedObjectFromStructure:childStructureDictionary withManagedObjectContext:moc]; [managedObject setValue:childObject forKey:relationshipName]; continue; } NSMutableSet *relationshipSet = [managedObject mutableSetValueForKey:relationshipName]; NSArray *relationshipArray = [structureDictionary objectForKey:relationshipName]; for (NSDictionary *childStructureDictionary in relationshipArray) { NSManagedObject *childObject = [self managedObjectFromStructure:childStructureDictionary withManagedObjectContext:moc]; [relationshipSet addObject:childObject]; } } return managedObject; } //method to call for obtaining managed objects from JSON structure - i.e. public interface to this class - (NSArray*)managedObjectsFromJSONStructure:(NSString *)json withManagedObjectContext:(NSManagedObjectContext*)moc { NSError *error = nil; NSArray *structureArray = [[CJSONDeserializer deserializer] deserializeAsArray:[json dataUsingEncoding:NSUTF32BigEndianStringEncoding] error:&error]; NSAssert2(error == nil, @"Failed to deserialize\n%@\n%@", [error localizedDescription], json); NSMutableArray *objectArray = [[NSMutableArray alloc] init]; for (NSDictionary *structureDictionary in structureArray) { [objectArray addObject:[self managedObjectFromStructure:structureDictionary withManagedObjectContext:moc]]; } return [objectArray autorelease]; } @end

    Read the article

  • long delay between serverside JSON and jqGrid loadComplete on asp.net mvc site

    - by ooo
    i have an asp.net mvc site where i load a jqgrid with json data public ActionResult GridData(GridData args) { IEnumerable<Application> applications = EntityModel.GetAll().ToList(); applications = FilterEntities(applications); if (args.sidx.IsNullOrEmpty() || args.sidx == "Id") { args.sidx = "Name"; args.sord = "asc"; } applications = applications.GridSort(args.sidx, args.sord); var paginatedData = applications.GridPaginate(args.page ?? 1, args.rows ?? 10, i => new { i.Id, Name = "<div class='showDescription' Id= '" + i.MyId + "'>" + i.Name + "</div>", MyId = string.Format("<a i.LastUpdated, i.LastUpdatedColumn }); return Json(paginatedData); } and here is my javascript code: function doInitCrudGrid(controller, names, model, editable, querystring) { jQuery("#grid").jqGrid({ mtype: 'POST', url: "/" + controller + "/GridData?" + querystring, datatype: "json", colNames: names, colModel: model, imgpath: "/Scripts/jqGrid/themes/steel/images", rowNum: 20, rowList: [10, 20, 50, 999], altRows: true, altclass: "altRow", jsonReader: { root: "Rows", page: "Page", total: "Total", records: "Records", repeatitems: false, id: "Id" }, pager: "#pager", height: "auto", sortname: "Id", viewrecords: true, sortorder: "desc", loadComplete: function() { alert("Load Complete"); }, ondblClickRow: function(rowid) { } }); i have a breakpoint on the return Json(paginatedData); line and that gets hit very quick but after that it takes about 10 seconds for the: alert("Load Complete"); and for the rendering to show up on the web page. Is there anyway to debug this or way to see why there would be this large delay between finishing the server side json and histting the loadcomplete on the javascript callback ?

    Read the article

  • parse json with ant

    - by paleozogt
    I have an ant build script that needs to pull files down from a web server. I can use the "get" task to pull these files down one by one. However, I'd like to be able to get a list of these files first and then iterate over the list with "get" to download the files. The webserver will report the list of files in json format, but I'm not sure how to parse json with ant. Are there any ant plugins that allow for json parsing?

    Read the article

  • How to serialize and unserialize to/from a C# class?

    - by Earlz
    Hello, I have an object in Javascript that looks like this function MyObject(){ this.name=""; this.id=0; this..... } I then stringify an array of those objects and send it to an ASP.Net web service. Now what I want to do is do some processing on the JSON objects given to the webservice and return a JSON array of the same type of objects(same field names and such) How would I do this easily? I am using Netwonsoft.Json. Is there some way to turn a JSON string into a List or Array of an object?

    Read the article

  • Problem passing json into jquery graph(flot)

    - by Adam McMahon
    I trying to retrieve some json to pass into a flot graph. I know that json is right because I hard coded it to check, but I'm pretty sure that I'm not passing right because It's not showing up. Here's the javascript: var total = $.ajax({ type: "POST", async: false, url: "../api/?key=xxx&api=report&crud=return_months&format=json" }).responseText; //var total = $.evalJSON(total); var plot = $.plot($("#placeholder"),total); here's the json: [ { data: [[1,12], [2,43], [3,10], [4,17], ], label: "E-File"}, { data: [[1,25], [2,35], [3,3], [4,5], ], label: "Bank Products" }, { data: [[1,41], [2,87], [3,30], [4,29], ], label: "All Returns" } ], {series: {lines: { show: true },points: { show: true }}, grid: { hoverable: true, clickable: true }, yaxis: { min: 0, max: 100 }, xaxis: { ticks: [[1,"January"],[2,"February"],[3,"March"],[4,"April"],[5,"May"],[6,"June"],[7,"July"],[8,"August"],[9,"September"],[10,"October"],[11,"November"],[12,"December"]] }}

    Read the article

  • Best json parser for qt?

    - by Martin
    I'm using QT for Symbian and need a simple json parser. I need to be able to go from json to Qt-variant and the other way around. Is there a simple json parser that I can use? I don't want to write my own. What is the best way to go? Thanks!

    Read the article

  • Parsing Json Feeds with google Gson

    - by mnml
    I would like to know how to parse a json feed by items, eg. url / title / description for each item. I have had a look to the doc / api but, it didn't help me. This is what I got so far import com.google.gson.Gson; import com.google.gson.JsonObject; public class ImportSources extends Job { public void doJob() throws IOException { String json = stringOfUrl("http://feed.test/all.json"); JsonObject jobj = new Gson().fromJson(json, JsonObject.class); Logger.info(jobj.get("responseData").toString()); } public static String stringOfUrl(String addr) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); URL url = new URL(addr); IOUtils.copy(url.openStream(), output); return output.toString(); } }

    Read the article

  • Spring 3 JSON with MVC

    - by stevedbrown
    Is there a way to build Spring Web calls that consume and produce application/json formatted requests and responses respectively? Maybe this isn't Spring MVC, I'm not sure. I'm looking for Spring libraries that behave in a similar fashion to Jersey/JSON. The best case would be if there was an annotation that I could add to the Controller classes that would turn them into JSON service calls. A tutorial showing how to build Spring Web Services with JSON would be great. EDIT: I'm looking for an annotation based approach (similar to Jersey). EDIT2: Like Jersey, I am looking for REST support (POST,GET,DELETE,PUT). EDIT3: Most preferably, this will be the pom.xml entries and some information on using the spring-js with jackson Spring native version of things.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >