json-encode

Reading JSON (with jQuery) produced by PHP containing @attributes

What are those "@attributes" thing I have in my JSON file and how can I read that with JQuery? The JSON "text" I use is produced with json_encode in PHP from an array of custom objects. Here's a reduced JSON file: { "movies" : [ { "url":"http:\/\/www.youtube.com\/watch?v=Nsd7ZcXnL6k", title":{"@attributes":{"type":"text"},"0":"**Title...

json_encode remove quotes from keys?

If I use json_encode() on an array like this: return json_encode(array( 'foo' => 'bar')); The return is: {'foo' : 'bar'} The key is passed as a literal, and that is tripping up my script. What I really need is: { foo : 'bar' } Does json_encode do that or do I have to strip the quotes out myself with some ugly regex? ...

json parsing in objective c

while parsing the content of a .json file, string like "jamie's" is represented as "jamie 's".Any one know why it is so? Thanks in advance for any help ...

json_encode adding unwanted slashes

Hello all I have a json string saved in my db. When i retrieve it from db to pass it to the javascript function (ajax call) , along with the id of that row, i am json_encoding both (the query result array) and passing it to js. but json_encode is adding unwanted slashes to my already json string. how to escape it. remember i have to pass...

PHP Json Encoding w/ quote escaping in 5.2?

I'm playing with the flickr api and php. I want to pass some information from PHP to Javascript through Ajax. I have the following code: json_encode($pics); which results in the following example JSON string: [{"id":"4363603591","title":"blue, white and red...another seattle view","date_faved":"1266379499"},{"id":"4004908219","titl...

I want to generate following JSON dataobject using org.json.simple.JSONObject, how to do it in java?

Hi all, I want to genrate following JSON dataobject using org.json.simple.JSONObject, how to do it in java? { friends : [ { name: 'David', interests: 'Cooking', }, { name: 'Charles', interests: 'Hiking', }, { name: 'Mary', interests: 'Football', }, ] } If code snipet is...

Not able to get the data from the JSON in OpenSocial App!

I have follwing JSON: {"mykey":[{name:"Jak",interests:"movies"}]} and following opensocial app code: <script type="text/os-template" require="mykey"> <ul> <li repeat="${mykey}"> <span>Offer id: ${Cur.name}</span> <span>Offer: ${Cur.interests}</span> ...

is this valid json array using php

Hello, I need to convert some code done by someone else, to work in my mvc model It is using some functions like EOD that I don't understand. Does that still work in a class? Primarely, my question focusus on the json output. The old code does not use the php json_encode function, but outputs it directly like this ?> { "use...

PHP: need json_encode() 5.3 functionality in 5.2

Long story short, client's hosting is using php 5.2.5 and i desperately need to use the JSON_FORCE_OBJECT option with json_encode() that came with 5.3. Does anyone know some equivalent for that purpose? Point it out please. ...

Help with OpenSSL request using Python

Hi i'm creating a program that has to make a request and then obtain some info. For doing that the website had done some API that i will use. There is an how-to about these API but every example is made using PHP. But my app is done using Python so i need to convert the code. here is the how-to: The request string is sealed with Ope...

Is PHP's json_encode guaranteed to produce ASCII string?

Well, the subject says everything. I'm using json_encode to convert some UTF8 data to JSON and I need to transfer it to some layer that is currently ASCII-only. So I wonder whether I need to make it UTF-8 aware, or can I leave it as it is. Looking at JSON rfc, UTF8 is also valid charset in JSON output, although not recommended, i.e. som...

JSON encoding on RTL languages

Hi, I'm using JSON to integrate open flash chart to my web page. When I have a Right to Left language string which contains more the one word the JSON encodes it backwards (For example: "Hello world" is encoded as "world hello"). The string is extracted from a database, there for can be of any language. How do I force the correct enc...

Serializing Python bytestrings to JSON, preserving ordinal character values

I have some binary data produced as base-256 bytestrings in Python (2.x). I need to read these into JavaScript, preserving the ordinal value of each byte (char) in the string. If you'll allow me to mix languages, I want to encode a string s in Python such that ord(s[i]) == s.charCodeAt(i) after I've read it back into JavaScript. The c...

UTF-8 character encoding battles json_encode()

Quest I am looking to fetch rows that have accented characters. The encoding for the column (NAME) is latin1_swedish_ci. The Code The following query returns Abord â Plouffe using phpMyAdmin: SELECT C.NAME FROM CITY C WHERE C.REGION_ID=10 AND C.NAME_LOWERCASE LIKE '%abor%' ORDER BY C.NAME LIMIT 30 The following displays expected va...

Escaping escape Characters

I'm trying to mimic the json_encode bitmask flags implemented in PHP 5.3.0, here is the string I have: $s = addslashes('O\'Rei"lly'); // O\'Rei\"lly Doing json_encode($s, JSON_HEX_APOS | JSON_HEX_QUOT) outputs the following: "O\\\u0027Rei\\\u0022lly" And I'm currently doing this in PHP versions older than 5.3.0: str_replace(array(...

how to use json_encode without PHP 5.2

I've written a CMS which uses the PHP function json_encode to send some data back via an Ajax Request. Unfortunately, I'm trying to load it onto a server which is running PHP version 5.1, the json_encode PHP function is not available on versions of PHP before 5.2.0. Does anyone know of a way to encode a PH array as JSON without using t...

[grails] JSON converter - stack overflow

Hi all, I'm trying to convert a domain class into JSON. def converter = null try{ converter = events as JSON } catch(e) { log.error "error during conversion to JSON" log.error e } return converter.toString() I always get this error: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executin...

php json_encode returning null

Array ( [sEcho] => 1 [iTotalRecords] => 7521 [iTotalDisplayRecords] => 1 [aaData] => Array ( [0] => Array ( [0] => Nordic Capital Buys SiC Processing [1] => 2010-06-21/nordic-capital-buys-sic-processing [2] => PEHub Media ...

Recursion for json_encode only on failed MySQL query

Scenario: Two different objects that get their data from a MySQL database (originally, then subsequently from a serialized/unserialized SESSION key) are causing a recursion error for json_encode, but ONLY when another, later INSERT query has failed. The INSERT query will fail when certain elements are NULL (as mandated by the table str...

Using Json and jQuery to populate DropDown from a list of custom classes in Asp.Net MVC 2

I'm trying to populate a DropDown from a Json result using jQuery. I have the following class: class MyOption { int Id { get; set; } string Name { get; set; } } I'm not sure how to get a list of these into my Json result. At the moment I have the following, I'm not sure if it's correct but it compiles and runs: return Json(...