json

How can a Javascript object refer to values in itself?

Hi, Lets say I have the following javascript: var obj = { key1 : "it ", key2 : key1 + " works!" }; alert(obj.key2); This errors with "key1 is not defined". I have tried this.key1 this[key1] obj.key1 obj[key1] this["key1"] obj["key1"] and they never seem to be defined. How can I get key2 to refer to key1's value? ...

Unable to return/process JSON in JQuery $.get()

I have a problem returning/processing JSON data while calling $.get() function. Here's the code: JQuery: $.get("script.php?", function(data) { if (data.status) { alert('ok'); } else { alert(data.error); } },'json'); PHP if ($r) { $ret =...

how to write the server side in php if i am using the json on client side of the iphone.

i want to make my server side in php. after writing the code in php can i directly use json to parse it of or something other required on the server side with php. can you give me some example of it, how to do this on server side if i want to use json of my client side. ...

xml data lost in JSON conversion

I am getting the following result from converting xml to JSON, using more than one conversion library. As you can see, the property name attributes are lost, as are the Item name attributes. Why? Does anyone have recommendations on how I might change my XML to make it more conversion friendly? <Asset name="xyz"> <Property name="p1">V...

Force lowercase property names from Json() in ASP.NET MVC

Given the following class, public class Result { public bool Success { get; set; } public string Message { get; set; } } I am returning one of these in a Controller action like so, return Json(new Result() { Success = true, Message = "test"}) However my client side f...

problem parsing JSON Strings

var records = JSON.parse(JsonString); for(var x=0;x<records.result.length;x++) { var record = records.result[x]; ht_text+="<b><p>"+(x+1)+" " +record.EMPID+" " +record.LOCNAME+" " +record.DEPTNAME+" " +record.CUSTNAME +"<br/><br/><div class='slide'>" +record.REPORT +"</div></p></b><br/>"; } The above co...

XML::XML2JSON "0" Element

I'm using XML::XML2JSON in Perl to convert JSON data to XML, I am passing through the following data (snippet): {"question":{"isrequired":{"$t":"0"}}} and when I use the XML:XML2JSON->json2xml function to convert the JSON data into XML, I get the following (snippet): <isrequired/> I need to retain the "0" element in the "isrequired...

JSON in COCOA (with YAJL)

at first, sry for my english... :) I'm using the YAJL Framework http://github.com/gabriel/yajl-objc My file look like this: [ [ 3753700, { "altitude" : 36950, "heading" : 129.918421384319, "latitude" : 47.554033252495699, "longitude" : 8.2125612837369903, "pointType" : "EXTRAPOLATED", "speed" ...

Can anybody help me out with this error.?

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where...

Using Jquery to get JSON objects from local file.

I'm trying to get a list of JSON objects (products) from a local file using Jquery and store all the objects in a single array called allItems. The file is co-located in the same directory as the code, and it's called "allItems.json". Here's how I'm doing it now: function getAllSupportedItems(){ var allItems = new Array(); $.g...

How do I stop a jQuery long-polling request?

I'm using... $.getJSON(url + "&callback=?", function (b) { ....... }); for a long-polling request. Sometimes it is necessary that I stop the current request being made. Is this possible? ...

Debuggerproblem

I have problem .. i get debugerror i will used in json 2009-02-13 18:32:17.405 xxxxxxxx[1491:20b] * -[NsDecimalNumber length]: unrecognized selector sent to instance 0xc3f10ff0 2009-02-13 18:32:17.406 xxxxxxxx[1491:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '** -[NsDecimalNumber length ]: unre...

toJSON "Object doesn't support this property or method"

I've a Javascript Class and its method. But when i call it toJSON is generating an error. I couldn't figure out why this error is happening. try { if (this.TabloEkId == undefined || this.TabloEkId == "") { throw errEksikVeri; } fAjaxSetup(fBefore, fSuccess, fError, fComplete); $.ajax({ type: "POST", ...

How can I serialize functions using JSON or some other serialization library?

I am trying to create a program that uses javascript to write a simple textadventure that I can then post on my blog and run on my iphone. I have run into a problem though. I was trying to make it so that my program would save it's state into cookies using JSON to convert it into strings and then post it into a cookie but then I realised...

SBJson returning nil causing cocoa window to not show up

I'm using the example here. If there isn't a value for the key, my application returns -[NSCFArray insertObject:atIndex:]: attempt to insert nil in the console, and my window doesn't show up. How could I preform a check to make sure this doesn't happen? ...

Use a JSON array with objects with javascript

Hi, I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this: Variable that I will pass to the function will look like this: [{"id":28,"Title":"Sweden"}, {"id":56,"Title":"USA"}, {"id":89,"Title":"England"}] function test(my...

Sending JSON(jQuery) to PHP and decoding it

I can't for the life of me figure out what I'm doing wrong. It seems like it should be simple because I can't find anyone else with this issue but I can't figure out to send basic data via javascript(jQuery) to PHP and decode it. For the sake of simplicity, this is what I have: JAVASCRIPT var json_data = { "name" : "john doe" }; $.a...

How to get an hierarchical php structure from a db table, in php array, or JSON

Possible Duplicate: Turn database result into array Hi guys, can you please help me. How to get an hierarchical php structure from a db table, in php array, or JSON, but with the following format: [{ "attributes" : {"id" : "111"}, "data" : "Some node title", "children" : [ { "attributes" : { "id" : "555"}, "data" : "A sub nod...

Python - Using "Google AJAX Search" API's Local Search Objects

Hi! I've just started using Google's search API to find addresses and the distances between those addresses. I used geopy for this, but, I often had the problem of not getting the correct addresses for my queries. I decided to experiment, therefore, with Google's "Local Search" (http://code.google.com/apis/ajaxsearch/local.html). Anywa...

Really simple JSON serialization in .NET

I have some simple .NET objects I'd like to serialize to JSON and back again. The set of objects to be serialized is quite small and I control the implementation, so I don't need a generic solution that will work for everything. Since my assembly will be distributed as a library I'd really like to avoid a dependency on some third-party D...