json

JSON.parse vs. eval()

My Spider Sense warns me that using eval() to parse incoming JSON is a bad idea. I'm just wondering if JSON.parse() - which I assume is a part of JavaScript and not a browser-specific function - is more secure. ...

Struts2 +JSON RPC

I have developed a native client interface which calls struts2 JSON RPC using post method. I have set content type, content length as suggested in the spec. The request body looks like as follows : {"method": "uploadTxpAssignment","id": "txpUploadRequest", "params":{"addressByDestAddrId":{"addrLine1":"test home","addrLine2":"7th ave","...

jQuery: Handle fallback for failed AJAX Request

Can jQuery provide a fallback for failed AJAX calls? This is my try: function update() { var requestOK = false; $.getJSON(url, function(){ alert('request successful'); requestOK = true; }); if (!requestOK) { alert('request failed'); } } Unfortunately, even if the callback function of the $...

how to build a 3statetree in flex

hi all I want build a 3statetree with checkbox,I had got the resource from cookbook,but I don't know how to use it with json, and how can i click one node then send the request to server and expand the subnode after receive the json data from server. thank you,thank you. ...

how to combine two different tables data into a single json object

iam making a json object by the following query $arr = array(); $qs=qq("select main_cat_id,main_cat_name,id,name,cat_id,cat_id_main from main,scheme where main_cat_name='xyz' and cat_id_main=main_cat_id"); while($obj = mysql_fetch_object($qs)) { $arr[] = $obj; } $total=sizeof($arr)...

jQuery "getJSON" from an external domain that doesn't support JSON-P output.

Hello, I'm trying to grab data from a JSON on an external site but the site doesn't support JSON-P output. This is an example of non-working code, but gives a good idea of what I'm trying to achieve: $.getJSON("http://www.bom.gov.au/fwo/IDV60901/IDV60901.94868.json", function(data){ //Process data here }); Are there ways around t...

Why does $.ajax call for json data trigger the error callback when http status code is "200 OK"?

I have the following ajax request: jQuery.ajax({ async: true, type: "GET", url: url, data: data, dataType: "json", success: function(results){ currentData = results; }, error: function(xhr, ajaxOptions, thrownError){ if (xhr.status == 200) { console.debug("Error code 200"); } else { cu...

Dojo dojo.rawXhrPost and dojo.xhrPost

My question is: can we use dojo.xhrPost to post some Json data? More detail: I have been experimenting with Dojo code to POST JSON data to a RESTful service. It seems to be that the behaviours of dojo.xhrPost and dojo.rawXhrPost are different, or to be more accurate rawXhrPost() works and xhrPost() does not. This is not consistent with ...

create a JSON DateTime string with .NET

For a strange reason that does not matter for this question I need to create a JSON compatible substring that represents a DateTime and that will be manually insterted into a larger JSON string that later will be parsed by .NET's DataContractJsonSerializer. I have come up with the following method: static readonly DataContractJsonSerial...

JSON Variable showing as text

I am not too savvy with JSON so any help would be great... I am loading a page via JQuery's .load. I am setting varname as a variable, but it is posting as the actual variable name not what I set it to. In other words it is showing up as "varname" instead of "class_id". var varname = "class_id"; $(this).siblings(".container").load(l...

Creating a class for JSON deserialization

Consider the following JSON: { "Code": 2, "Body": { "Dynamic-Key": { "Key1": "Val1", "Key2": "Val2" } } } Defining the following classes structure: [DataContract] class JsonResponse { [DataMember] public string Code { get; set; } [DataMember] public JsonResponseBo...

How do I parse this JSON?

I'm using a book API that returns the following var _OLBookInfo = { "ISBN:234234234234234": { "bib_key": "ISBN:234234234234234", "preview": "noview", "preview_url": "http://openlibrary.org/b/adsfasdfa", "info_url": "http://openlibrary.org/b/adsfasdf", "details": { "publishers":...

When do I need to use JSON and XML?

I know there are a lot of sources which explain this, but they just talk about storing key/value pairs in an array or in an object. I can't understand why or when should I do this, although I always use jquery's AJAX. As an example, if I make a forum when do I need this? Can someone give real world examples? The same goes for XML. It s...

How can I retrieve a feed in JSON from a Java Servlet?

I want to make an Http request and store the result in a JSONObject. I haven't worked much with servlets, so I am unsure as to whether I am 1) Making the request properly, and 2) supposed to create the JSONObject. I have imported the JSONObject and JSONArray classes, but I don't know where I ought to use them. Here's what I have: ...

json jquery php question

i dont understand one thing. if i want to get JSON data (key-value-pairs) from php to jquery using ajax...which of these following ones should i use? $.get $.post $.getJSON do i need to use getJSON if i want to use json_encode in php file? but what if i want to send with post? (there is no postJSON)? and one more thing: in php fil...

jquery ajax get json array?

i use $.getJSON to call php file. it echos this back. for($i=0; $i<=10; $i++) { $nr[] = $i; } echo "{'result': 'error', 'count': '$nr'}"; in jquery to get result i just use alert(data.result) how do i get all the nr:s in count? EDIT: But how do i loop the array through in jquery? All the keys are numeric and i dont know how to...

loop through a json numeric array?

i use $.getJSON and here is my php file echo:ing back jsonstring for($i=1; $i<=10; $i++) { $nr[] = "nr" . $i; } $nr = json_encode($nr); echo "{'result': 'error', 'count': '$nr'}"; how do i loop all the nr through with jquery html()? i want to echo it back to webpage like: nr 1 nr 2 nr 3 nr 4 nr 5 nr 6 nr 7 nr 8 nr 9 nr 10 ...

How to Obtain Data to Pre-Populate Forms.

The objective is to have a form reflect user's defined constraints on a search. At first, I relied entirely upon server-side scripting to achieve this; recently I tried to shift the functionality to JavaScript. On the server side, the search parameters are stored in a ColdFusion struct which makes it particularly convenient to have t...

sending back json string with echo problem

i use json_encode to send back data from php to jquery through ajax. and i have noticed that jquery just allow us to use ONE echo in php. if i use echo json_encode($array);.... and then one more echo json_encode($array2); in the same php file, then it would not work. or if i use echo json_encode($array); and then another echo "hello";...

Recommended approach for linq to sql serialization for simple json and mvc

I have cascading drop down lists in a .net mvc view and am using JQuery onchange to pull the next drop down list using a json response. The problem comes in where iI get a circular reference when trying to serialize the linq to sql response. I understand why it is happening, its because I have the buyer -> contracts and contract -> b...