Search Results

Search found 4865 results on 195 pages for 'json'.

Page 7/195 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Multipart question: Mapping between xml and Json using xpath

    - by scope-creep
    This is a JSON mapping question from a json newbie. Currently i'm reading xml using xpath in C#, and the xpath are returning either the element or attribute node values, as is the schema's want. I want to write out some of the returned values into a json formatted file. I know i can faneigle the xpath expression to return the element or attribute names, so I can built the appropriate name/value json structure before serialization, but I was I'm wondering if their was some way of doing a mapping between the xml and json. The xml schema is fairly big, so potentially the mapping will be big, meaning a ton of cumbersom coding to make it work. Is their any way to automap somehow? I was planning to use json.net, which seems flexible enough, although their may be a better approach. Any help would be appreciated. Bob.

    Read the article

  • Not Recieving JSON object into my Zend Controller

    - by davykiash
    Am am sucessfully parsing and sending json values from my client for my server side controller to recieve and parse $("#test2").click(function() { $.ajax({ type: "POST", url: "<?php echo $this->baseUrl() ?>/expensetypes/add", data: JSON.stringify(wrapFormValues($('#expensetypes'))), contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg){ alert( "Data Saved: " + msg ); } }); }); However in my controller the code $this->getRequest()->getPost() doesnt seem to recieve the json object that my client is sending though firebug clearly shows that my json object is being parsed and sent. What am I missing?

    Read the article

  • valid json still fails on IE with jquery's ajax or getJSON callbacks

    - by lock
    everytime my page loads, im supposed to create a datatable (also a jquery plugin) but when im fetching the contents, using .ajax or .getJSON always goes straight ahead to the error function, without even telling me what went wrong inside the callback $.ajax({ cache: false, type: "POST", url: oSettings.sAjaxSource, data: {'newdate' : date}, contentType: "application/json; charset=utf-8", dataType: "json", success: function(json) { console.log('retrieving json data'); }, error: function() { console.log("An error has occurred. Please try again."); } }); that's the actual code with the callback stripped for security purposes... this works fine in firefox which actually executes what's on the callback function but IE simply fails and proceeds to writing my log i've read alot that the primary reason the JSON calls fails for IE is whenever there are trailing commas or simply malformed JS but i used JSONLint already and verified that my json object is a valid one :(

    Read the article

  • Problem Fetching JSON Result with jQuery in Firefox and Chrome (IE8 Works)

    - by senfo
    I'm attempting to parse JSON using jQuery and I'm running into issues. Using the code below, the data keeps coming back null: <!DOCTYPE html> <html> <head> <title>JSON Test</title> </head> <body> <div id="msg"></div> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $.ajax({ url: 'http://datawarehouse.hrsa.gov/ReleaseTest/HGDWDataWebService/HGDWDataService.aspx?service=HC&zip=20002&radius=10&filter=8357&format=JSON', type: 'GET', dataType: 'json', success: function(data) { $('#msg').html(data[0].title); // Always null in Firefox/Chrome. Works in IE8. }, error: function(data) { alert(data); } }); </script> </body> </html> The JSON results look like the following: {"title":"HEALTHPOINT TYEE CAMPUS","link":"http://www.healthpointchc.org","id":"tag:datawarehouse.hrsa.gov,2010-04-29:/8357","org":"HEALTHPOINT TYEE CAMPUS","address":{"street-address":"4424 S. 188TH St.","locality":"Seatac","region":"Washington","postal-code":"98188-5028"},"tel":"206-444-7746","category":"Service Delivery Site","location":"47.4344818181818 -122.277672727273","update":"2010-04-28T00:00:00-05:00"} If I replace my URL with the Flickr API URL (http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?), I get back a valid JSON result that I am able to make use of. I have successfully validated my JSON at JSONLint, so I've run out of ideas as to what I might be doing wrong. Any thoughts? Update: I had the client switch the content type to application/json. Unfortunately, I'm still experiencing the exact same problem. I also updated my HTML and included the live URL I've been working with. Update 2: I just gave this a try in IE8 and it works fine. For some reason, it doesn't work in either Firefox 3.6.3 or Chrome 4.1.249.1064 (45376). I did notice a mistake with the data being returned (the developer is returning a collection of data, even for queries that will always return a single record), but it still baffles me why it doesn't work in other browsers. It might be important to note that I am working from an HTML file on my local file system. I thought it might be a XSS issue, but that doesn't explain why Flickr works.

    Read the article

  • JSON - Php/SQL iPhone APP Questions/Help

    - by chance
    Hey group, first time posting here I am somewhat new to the JSON/PHP/mySQL world, but been around iPhone designing for the past few years, though this topic of conversation is a while new area I am entering. I have done JSON iPhone examples that allow me to create a UITableView and display the JSON data into the TableViewCells (CustomCells) and displays the data (NSDictionary)into UILabels The problem I am having now, is that I want an APP that displays this information from the JSON into just a couple of UILabel's on a regular UIViewController and not a UITableView any help would greatly be appreciated, the example I used and learned for JSON and UITABLE was from http://tempered.mobi/%20 I used that example from my app, but incorporated a few other things like CUSTOM cells however now when the USER selects the specific CELL I want it to load specific data from another JSON file, and cannot get it to load in a UILabel or UITextView in a UIViewController HELP :-)

    Read the article

  • Selecting a portion of a JSON array and applying variables in javascript or jquery

    - by user1644609
    I am retrieving a JSON file that returns its results like what you see below. The JSON has 365 days worth of data. I would like to create "views" of this JSON using javascript, one which pulls the last 10 days, then 1 month, 6 months, etc. After the getJSON function I am doing this to get a string as JSON, then turn it into an object and will then graph it. So I would like each "view" to be an object for the specified timeframe (using the one JSON). The obj_10days, obj_1month, etc variables would then be plotted. var $ graph = data ; var obj = $ . parseJSON ( $ graph ) ; JSON: [ { "Low": 8.63, "Volume": 14211900, "Date": "2012-10-26", "High": 8.79, "Close": 8.65, "Adj Close": 8.65, "Open": 8.7 }, { "Low": 8.65, "Volume": 12167500, "Date": "2012-10-25", "High": 8.81, "Close": 8.73, "Adj Close": 8.73, "Open": 8.76 }, { "Low": 8.68, "Volume": 20239700, "Date": "2012-10-24", "High": 8.92, "Close": 8.7, "Adj Close": 8.7, "Open": 8.85 }, Any help is appreciated, thank you!

    Read the article

  • Should all new web projects build their backend based on xml/json result sets?

    - by Blankman
    If you were building a new Saas project, would it make sense to start with all of the backend services returning xml/json? Because these days you need to build for both the web and mobile devices, and having a backend that is build from the start to return xml and json, you are ready to go mobile (all services have the business logic, so you won't be repeating anything). Now the web would be MVC, so the controller would just be routing the request to your service backend, and converting the json or xml to html. The obviousl downside is that you have to build a backend, and then another web project that calls your backend. But this also goes to you favor as it forces you to seperate your concerns, and not leak business logic in your controller/view layer. Thoughts?

    Read the article

  • Is it convenient to use a XML/JSON generated based system? [closed]

    - by Marcelo de Assis
    One of my clients insists that we missed a requisite for the project(a little social network, using PHP + MySql), is that all queries are made from XML / JSON static files (using AJAX) and not directly from the database. Edit: The main reason, stated by client, is a way to economize bandwith. Even the file loading, has to be using AJAX, to avoid server side processing. We will still use a database to store and insert data. These XML / JSON files will be (re) generated whenever any data is changed by CMS or users. As the project was developed without this "technique", we'll have a lot of work ahead, so I would like to avoid that. I'm asking if it's convenient to use a XML generated based system, because I think a database is already "optimized" and secure to deal with a lot of data traffic. Other issue I'm afraid of, is a chance of conflict when a user is trying to read a XML/JSON which is being just generated.

    Read the article

  • What is the need of Odata when I have JSON ?

    - by punkouter
    I am trying to understand the point of Odata and when it would make sense. Right now how I work is I use ASP.NET and MVC/WebApi controller to serialize/deserialize objects into JSON and have javascript do something with it. From what I can tell the benefit of OData is being able to query directly from the URL ... But since I am writing the client and server code there is no need for that. Would anyone ever parse the results of a ODaya query in javascript?? Maybe OData is more about providing a generic endpoint for ALL clients to get detailed information from a query that JSON does not provide ? So if I was a provider of data then I suppose that is what odata is for ? Help me understand the purpose and use of REST/JSON/ODATA.

    Read the article

  • How best to merge/sort/page through tons of JSON arrays?

    - by Joshiatto
    Here's the scenario: Say you have millions of JSON documents stored as text files. Each JSON document is an array of "activity" objects, each of which contain a "created_datetime" attribute. What is the best way to merge/sort/filter/page through these activities via a web UI? For example, say we want to take a few thousand of the documents, merge them into a gigantic array, sort the array by the "created_datetime" attribute descending and then page through it 10 activities at a time. Also keep in mind that roughly 25% of these JSON documents are updated every day, and updates have to make it into the view within 5 minutes. My first thought is to parse all of the documents into an RDBMS table and then it would just be a simple query such as "select top 10 name, created_datetime from Activity where user_id=12345 order by created_datetime desc". Some have suggested I use NoSQL techniques such as hadoop or map/reduce instead. How exactly would this work? For more background, see: Why is NoSQL better for this scenario?

    Read the article

  • Philosophy of [WebInvoke(ResponseFormat = WebMessageFormat.Json)]

    - by Mikey Cee
    Hi everyone, I'm writing what I'm referring to as a POJ (Plain Old JSON) WCF web service - one that takes and emits standard JSON with none of the crap that ASP.NET Ajax likes to add to it. It seems that there are three steps to accomplish this: Change to in the endpoint's tag Decorate the method with [WebInvoke(ResponseFormat = WebMessageFormat.Json)] Add an incantation of [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] to the service contract This is all working OK for me - I can pass in and am being returned nice plain JSON. If I remove the WebInvoke attribute, then I get XML returned instead, so it is certainly doing what it is supposed to do. But it strikes me as odd that the option to specify JSON output appears here and not in the configuration file. Say I wanted to expose my method as an XML endpoint too - how would I do this? Currently the only way I can see would be to have a second method that does exactly the same thing but does not have WebMethodFormat.Json specified. Then rinse and repeat for every method in my service? Yuck. Specifying that the output should be serialized to JSON in the attribute seems to be completely contrary to the philosophy of WCF, where the service is implemented is a transport and encoding agnostic manner, leaving the nasty details of how the data will be moved around to the configuration file. Is there a better way of doing what I want to do? Or are we stuck with this awkward attribute? Or do I not understanding WCF deeply enough?

    Read the article

  • Problem Parsing JSON Result with jQuery

    - by senfo
    I am attempting to parse JSON using jQuery and I'm running into issues. In the code below, I'm using a static file, but I've also tested using an actual URL. For some reason, the data keeps coming back as null: <!DOCTYPE html> <html> <head> <title>JSON Test</title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $.getJSON('results.json', function(data) { alert(data); // Result is always null }); </script> </head> <body> </body> </html> The JSON results look like the following: {"title":"HEALTHPOINT TYEE CAMPUS","link":"http://www.healthpointchc.org","id":"tag:datawarehouse.hrsa.gov,2010-04-29:/8357","org":"HEALTHPOINT TYEE CAMPUS","address":{"street-address":"4424 S. 188TH St.","locality":"Seatac","region":"Washington","postal-code":"98188-5028"},"tel":"206-444-7746","category":"Service Delivery Site","location":"47.4344818181818 -122.277672727273","update":"2010-04-28T00:00:00-05:00"} If I replace my URL with the Flickr API URL (http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?), I get back a valid JSON result that I am able to make use of. I have successfully validated my JSON at JSONLint, so I've run out of ideas as to what I might be doing wrong. Any thoughts?

    Read the article

  • YUI "Get" utility to parse JSON response?

    - by Sean
    The documentation page for the YUI "Get" utility says: Get Utility is ideal for loading your own scripts or CSS progressively (lazy-loading) or for retrieving cross-domain JSON data from sources in which you have total trust. ...but doesn't have any actual examples for how to do so. Their one example doesn't actually request a JSON document from a remote server, but instead a document containing actual JavaScript along with the JSON data. I'm just interested in the JSON response from the Google Maps API HTTP (REST) interface. Because I can't do cross-site scripting with the "Connect" utility, I am trying the "Get" utility. But merely inserting some JSON data into the page isn't going to do anything, of course. I have to assign it to a variable. But how? Also, just inserting JSON data into the page makes Firefox complain that there's a JavaScript error. And understandably! Plain ol' JSON data isn't going to parse as valid JavaScript. Any ideas?

    Read the article

  • Undefined variable error when parsing json

    - by Ben Shelock
    I'm trying to parse the json grabbed from here. Basically what I do is iterate over the items, sort them, then display them. But I get an error saying data.data.children[i] is undefined. I can't think why it's doing it though? var json = 'http://www.reddit.com/reddits/mine/.json'; GM_xmlhttpRequest({ method: "GET", url: json, onload: reddits }); function reddits(response){ var txt = response.responseText; var data; var suggested = document.getElementById('suggested-reddits'); if(window.JSON && JSON.parse){ data = JSON.parse(txt); } else{ data = eval("("+txt+")"); } suggested.innerHTML += '<span>reddits you\'re subscribed to </span> <ul id="rsub"></ul>'; GM_addStyle('#rsub{width: 500px;}'); var reddits = new Array(); var rsub = document.getElementById('rsub'); for(i = 0; i <= data.data.children.length; i++){ var r = data.data.children[i].data.display_name; reddits.push(r); } sort(reddits); for(i = 0; i <= reddits.length; i++){ rsub.innerHTML += '<li><a href="#" onclick="set_sr_name(this); return false">' + reddits[i] + '</a></li>'; } }

    Read the article

  • Bizarre Javascript JSON undefined error

    - by Nate C-K
    I'm experiencing an error that I haven't been able to find any mention of anywhere. I'm developing an AJAX-enabled WCF web service with ASP.NET. In my ASP.NET master page's , I included the json.js file, copied fresh from json.org. When I run the page, it fails (VS 2008 catches a Javascript exception) on the first line of code in json.js (following lots of comments), which is: JSON = JSON || {}; The error says that JSON is undefined: Microsoft JScript runtime error: 'JSON' is undefined Well, duh! That's why the line is testing if it's defined and if so setting it to an empty object! It is supposed to be undefined, right? Last I heard it was not an error in Javascript to perform such an operation on an undefined variable. Can anyone give me a clue as to what's going on here? I suspect it's something gone wrong elsewhere that's somehow causing this problem. I don't have deep experience with either Javascript or ASP.NET so it might be that I'm missing some common gotcha in the setup.

    Read the article

  • confused about how to use JSON in C#

    - by Josh
    The answer to just about every single question about using C# with json seems to be "use JSON.NET" but that's not the answer I'm looking for. the reason I say that is, from everything I've been able to read in the documentation, JSON.NET is basically just a better performing version of the DataContractSerializer built into the .net framework... Which means if I want to deserialize a JSON string, I have to define the full, strongly-typed class for EVERY request I might have. so if I have a need to get categories, posts, authors, tags, etc, I have to define a new class for every one of these things. This is fine if I built the client and know exactly what the fields are, but I'm using someone else's api, so I have no idea what the contract is unless I download a sample response string and create the class manually from the JSON string. Is that the only way it's done? Is there not a way to have it create a kind of hashtable that can be read with json["propertyname"]? Finally, if I do have to build the classes myself, what happens when the API changes and they don't tell me (as twitter seems to be notorious for doing)? I'm guessing my entire project will break until I go in and update the object properties... So what exactly is the general workflow when working with JSON? And by general I mean library-agnostic. I want to know how it's done in general, not specifically to a target library... I hope that made sense, this has been a very confusing area to get into... thanks!

    Read the article

  • Combining JSON Arrays

    - by George
    I have 3 json arrays, each with information listed in the same format: Array: ID: NAME: DATA: ID: NAME: DATA: etc... My goal is to combine all 3 arrays into one array, and sort and display by NAME by passing the 3 arrays into a function. The function I've tried is: JSCRIPT Call: // to save time I'm just passing the name of the array, I've tried passing // the full array name as json[0]['DATA'][array_1][0]['NAME'] as well. combineNames(['array_1','array_2']); FUNCTION: function combineNames(names) { var allNames = [] for (i=0;i<names.length;i++) { for (j=0;j<json[0]['DATA'][names[i]].length;j++) { allNames.push(json[0]['DATA'][names[i]][j]['NAME']); } } return allNames.sort(); } The above gives me the error that NAME is null or undefined. I've also tried using the array.concat function which works when I hard code it: var names = []; var allNames = []; var names = names.concat(json[0]['DATA']['array_1'],json[0]['DATA']['array_2']); for (i=0;i<names.length;i++) { allNames.push(names[i]['NAME']); } return allNames.sort(); But I can't figure out how to pass in the arrays into the function (and if possible I would like to just pass in the array name part instead of the whole json[0]['DATA']['array_name'] like I was trying to do in the first function...

    Read the article

  • ANDROID IF/ELSE FAILS CONTINUES TO EXECUTE JSON

    - by Keith Cesar Haizlett
    I am trying to create a Registration app with JSON to connect and post to MYSQL database. I created the following IF/ELSE statements to check for vacant input boxes, password match, and correct email characters before allowing it to be entered into the DATABASE. The code continues to execute the JSON posting even after the passwords don't match , invalid email characters are entered , and vacant text boxes are submitted. Why is it not returning and continuing to execute the JSON code? try { if (!inputEmail.getText().toString().matches("[a-zA-Z0-9._-]+@[a-z]+.[a-z]+") && email.length() > 0) { Toast.makeText(getApplicationContext(), "Enter Valid Email Address", Toast.LENGTH_LONG).show(); return; } else if(name.equals("") || email.equals("")|| password.equals("")||check.equals("")) { Toast.makeText(getApplicationContext(), "Field Vaccant", Toast.LENGTH_LONG).show(); return; } // check if both password matches else if(!password.equals(checkpass)) { Toast.makeText(getApplicationContext(), "Password does not match", Toast.LENGTH_LONG).show(); return; } if (json.getString(KEY_SUCCESS) != null) { registerErrorMsg.setText(""); String res = json.getString(KEY_SUCCESS); if(Integer.parseInt(res) == 1){ // user successfully registred // Store user details in SQLite Database DatabaseHandler db = new DatabaseHandler(getApplicationContext()); JSONObject json_user = json.getJSONObject("user"); // Clear all previous data in database userFunction.logoutUser(getApplicationContext()); db.addUser(json_user.getString(KEY_NAME), json_user.getString(KEY_EMAIL), json.getString(KEY_UID), json_user.getString(KEY_CREATED_AT)); // Launch Dashboard Screen Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class); // Close all views before launching Dashboard dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(dashboard); // Close Registration Screen finish(); }else{ // Error in registration registerErrorMsg.setText("User already Registered"); } } } catch (JSONException e) { } } });

    Read the article

  • How to Compress JSON with ASP?

    - by s15199d
    I have a large JSON data string that's 757KB. I tried GZIP'ing it, which successfully reduced file size down to 143KB. But, in it's GZIP'ed state, my JQUERY function can't make use of the compressed JSON data. Any suggestions on how to compress JSON in an IIS/ASP environment and still be able to use the JSON data in a JQUERY function?

    Read the article

  • Convert JSON query parameters to objects with JAX-RS

    - by deamon
    I have a JAX-RS resource, which gets its paramaters as a JSON string like this: http://some.test/aresource?query={"paramA":"value1", "paramB":"value2"} The reason to use JSON here, is that the query object can be quite complex in real use cases. I'd like to convert the JSON string to a Java object, dto in the example: @GET @Produces("text/plain") public String getIt(@QueryParam("query") DataTransferObject dto ) { ... } Does JAX-RS support such a conversion from JSON passed as a query param to Java objects?

    Read the article

  • iPhone JSON Object

    - by Cosizzle
    Hello, I'm trying to create a application that will retrieve JSON data from an HTTP request, send it to a the application main controller as a JSON object then from there do further processing with it. Where I'm stick is actually creating a class that will serve as a JSON class in which will take a URL, grab the data, and return that object. Alone, im able to make this class work, however I can not get the class to store the object for my main controller to retrieve it. Because im fairly new to Objective-C itself, my thoughts are that im messing up within my init call: -initWithURL:(NSString *) value { responseData = [[NSMutableData data] retain]; NSString *theURL = value; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; return self; } The processing of the JSON object takes place here: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSError *jsonError; SBJSON *json = [[SBJSON new] autorelease]; NSDictionary *parsedJSON = [json objectWithString:responseString error:&jsonError]; // NSArray object. listings = [parsedJSON objectForKey:@"posts"]; NSEnumerator *enumerator = [listings objectEnumerator]; NSDictionary* item; // to prove that it does work. while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } [responseString release]; } Now when calling the object within the main controller I have this bit of code in the viewDidLoad method call: - (void)viewDidLoad { [super viewDidLoad]; JSON_model *jsonObj = [[JSON_model alloc] initWithURL:@"http://localhost/json/faith_json.php?user=1&format=json"]; NSEnumerator *enumerator = [[jsonObj listings] objectEnumerator]; NSDictionary* item; // while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } }

    Read the article

  • Java - JSON Null Exception

    - by user1112111
    Hi, I'm using JSON to deserialize an input string that contains a null value for certain hashmap property. Does anyone have any clue why this exception occurs ? Is it possible that null is not accepted as a value Is this configurable somehow ? input sample: {"prop1":"val1", "prop2":123, "prop3":null} stacktrace: net.sf.json.JSONException: null object at net.sf.json.JSONObject.verifyIsNull(JSONObject.java:2856) at net.sf.json.JSONObject.isEmpty(JSONObject.java:2212) Thanks.

    Read the article

  • Rails escape_javascript creates invalid JSON by escaping single quotes

    - by Arrel
    The escape_javascript method in ActionView escapes the apostrophe ' as backslash apostrophe \', which gives errors when parsing as JSON. For example, the message "I'm here" is valid JSON when printed as: {"message": "I'm here"} But, <%= escape_javascript("I'm here") %> outputs "I\'m here", resulting in invalid JSON: {"message": "I\'m here"} Is there a patch to fix this, or an alternate way to escape strings when printing to JSON?

    Read the article

  • ASP.Net JSON Web Service Post Form Data

    - by Will D
    I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json formatted data. This much is working for me, but ASP.Net has a requirement that parameters to the web service must be in json in order to get json out. I'm using jquery to run my ajax calls and there doesn't seem to be an easy way to create a nice javascript object from the form elements. I have looked at serialiseArray in the json2 library but it doesn't encode the field names as property name in the object. If you have 2 form elements like this <input type="text" name="namefirst" id="namefirst" value="John"/> <input type="text" name="namelast" id="namelast" value="Doe"/> calling $("form").serialize() will get you the standard query string namefirst=John&namelast=Doe calling JSON.stringify($("form").serializeArray()) will get you the (bulky) json representation [{"name":"namefirst","value":"John"},{"name":"namelast","value":"Doe"}] This will work when passing to the web service but its ugly as you have to have code like this to read it in: Public Class NameValuePair Public name As String Public value As String End Class <WebMethod()> _ Public Function GetQuote(ByVal nvp As NameValuePair()) As String End Function You would also have to wrap that json text inside another object nameed nvp to make the web service happy. Then its more work as all you have is an array of NameValuePair when you want an associative array. I might be kidding myself but i imagined something more elegant when i started this project - more like this Public Class Person Public namefirst As String Public namelast As String End Class which would require the json to look something like this: {"namefirst":"John","namelast":"Doe"} Is there an easy way to do this? Obviously it is simple for a form with two parameters but when you have a very large form concatenating strings gets ugly. Having nested objects would also complicate things The cludge I have settled on for the moment is to use the standard name value pair format stuffed inside a json object. This is compact and fast {"q":"namefirst=John&namelast=Doe"} then have a web method like this on the server that parses the query string into an associate array. <WebMethod()> _ Public Function AjaxForm(ByVal q As String) as string Dim params As NameValueCollection = HttpUtility.ParseQueryString(q) 'do stuff return "Hello" End Sub As far a cludges go this one seems reasonably elegant in terms of amount of code, but my question is: is there a better way? Is there a generally accepted way of passing form data to asp.net web/script services?

    Read the article

  • JSON and WebOS simple example?

    - by user558361
    I have been following this tutorial http://tinyurl.com/327p325 which has been GREAT up until this point where I can't get his code to work. I get the list working with static items but I can't get it to work with the json items. I've tried to simplify it with what I really want it to do to try and debug what is wrong (also if someone could please tell me how to view the Mojo log that would be awesome) In the tutorial he has to use the yahoo service to convert the site into json data, while the site I want to interact with already has json data generated so this is what I have PageAssistant.prototype.setup = function() { this.myListModel = { items : [] }; this.myListAttr = { itemTemplate: "page/itemTemplate", renderLimit: 20, }; this.controller.setupWidget("MyList",this.myListAttr,this.myListModel); this.controller.setupWidget("search_divSpinner", { spinnerSize : "large" }, { spinning: true } ); }; PageAssistant.prototype.activate = function(event) { this.getData(); }; PageAssistant.prototype.getData = function () { // the spinner doesn't show up at all $("search_divScrim").show(); var url = "http://www.website.com/.json"; var request = new Ajax.Request(url, { method: 'get', asynchronous: true, evalJSON: "false", onSuccess: this.parseResult.bind(this), on0: function (ajaxResponse) { // connection failed, typically because the server is overloaded or has gone down since the page loaded Mojo.Log.error("Connection failed"); }, onFailure: function(response) { // Request failed (404, that sort of thing) Mojo.Log.error("Request failed"); }, onException: function(request, ex) { // An exception was thrown Mojo.Log.error("Exception"); }, }); } PageAssistant.prototype.parseResult = function (transport){ var newData = []; var theStuff=transport.responseText; try { var json = theStuff.evalJSON(); } catch(e) { Mojo.Log.error(e); } // this is where I believe I am wrong for (j=0;j < json.data.count;j++) { var thread=json.data.children[j]; newData[j] = { title: thread.data.author }; } this.myListModel["items"] = newData; this.controller.modelChanged(this.myListModel , this); $("search_divScrim").hide(); } So where I commented that I believe I am wrong I am just trying to get the title out of this json data { kind: Listing data: { children: [ { kind: food data: { author: Foodmaster hidden: false title: You should eat this } }, // then it repeats with the kind: and data Anyone see where I went wrong? I would like to know how to view the log as I have log events but can't figure out where to look to see if any of them are being thrown.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >