Tag Archives: json

How to decode JSON values in my Android Aplication?

Questions: Hello guys I’m trying to decode a JSON value into my Android Application, But I’m not really sure What Am I doing wrong in my code… This is my PHP file: <?php … echo json_encode($mostrar_player); … ?> Which Will return me something like this: [“1″,”Admin”,”123″,”Adm”,”messages”,”0″] in my Android Application I need to put that… Read More »

Helping using JSON for an API

Questions: I don’t really understand how this API is supposed to work, as I’ve never worked with JSON before. The documentation doesn’t give any examples, but it says it the end-points in this API support both POST and GET operations, returning JSON. My question is, I’m not sure exactly how to implement this, let’s say… Read More »

check if a value exists in json encode array in mysql

Questions: I am working on a Mysql trigger to do something on my database. Before any thing, I want to check if a value exists in a json_encode string in my config table and after that proceed to run the trigger. my config table is handled by php scripts and looks like this: ——————————————- |… Read More »

Help editing JSON to make an array rather than a 'dictionary'

Questions: I currently have json using json_encode from a mysql query which looks like this: {“post_2”:{“caption”:”…”,”id”:”…”,”accountID”:”..”,”date”:”07\/07\/2011 1:45:12 AM”,”title”:”…”,”authorInfo”:{“Email Address”:”…”}}}, {“post_2”:{“caption”:”…”,”id”:”…”,”accountID”:”..”,”date”:”07\/07\/2011 1:45:12 AM”,”title”:”…”,”authorInfo”:{“Email Address”:”…”}}} How can I have the json being an array of posts (‘post_2’, ‘post_1’) rather than it being a dictionary? The JSON will be decoded on an iPhone using SBJSON and the JSON… Read More »

Read Json/Array string in Php

Questions: I have a string which is in valid Json format and it looks like this: { “message”: “success”, “result”: { “46620”: { “course_id”: “29”, “en_title”: “Google Analytics (Basic)”, “fa_title”: “مبانی Ú¯ÙˆÚ¯Ù„ آنالیتیکز”, “badge_link”: “http://www.darsnameh.com/badge/index.php?user=46620&badge=” }, “49449”: { “course_id”: “16”, “en_title”: “Multimedia Reporting 1- Reporting in the Internet Age”, “fa_title”: “گزارش‌گری چندرسانه‌ای Û±- گزارشگری در… Read More »

How to return JSON Object from PHP to read from Android App

Questions: I have the following MySQL table. I need to send the dealer name from android app and send all matching rows to the app.I dont know how to set the php output.I know i should encode using json_encode(array(‘stuff’)); But i dont know how to format the data.Been checking http://www.w3schools.com/json/ It shows an example {“employees”:[… Read More »

JSON.parse: unexpected character

Questions: I’m trying to pass a json from php jquery, after getting into an array of sql query and get the following javascript error. JSON.parse: unexpected character The function to return result of sql: public function selectassocSql($sql){ $i = 0; $resSelect = array(); mysql_query(“SET NAMES ‘utf8′”); $result = mysql_query($sql); while ( $row = mysql_fetch_assoc($result) )… Read More »

How to process JSON in PHP?

Questions: Here is the JSON which is sent asynchronously to my php page. It is essentially a product list, which will be inserted into my mySQL database. My issue is decoding the JSON in PHP. I can do this fine in js with the ‘eval’ function, but in PHP my efforts have resulted in a… Read More »

convert mysql result to json with correct types

Questions: I know how to get a mysql-row and convert it to json: $row = mysqli_fetch_assoc(mysqli_query($db, “SELECT * FROM table WHERE id=1”)); echo json_encode($row); // it’s an ajax-call but: the db-row has different types like int, float, string. by converting it using json_encode() all results are strings. Is there a better way to correct the… Read More »

change json key name [ json generated using json_encode ]

Questions: I am generating json from an array using json_encode(), it’s working properly, but it uses the key:value from the array, as usual. but I want to change the name of the key only in the json output.. is it possible to do it ? or should I prepare the json key:values myself manually ?… Read More »