473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

JSON

Hi,

I have a file that returns JSON data:

<?php
$q = strtolower($_GET["q"]);
if (!$q) return;
$items = array(
"Peter Pan"=>"pe***@pan.de",
"Molly"=>"mo***@yahoo.com",
"Forneria Marconi"=>"li**@japan.jp",
"Master Sync"=>"20***@samsung.com",
"Dr. Tech de Log"=>"g1*@logitech.com",
"Don Corleone"=>"do*@vegas.com",
"Mc Chick"=>"in**@donalds.org",
"Donnie Darko"=>"dd@timeshift.info",
"Quake The Net"=>"we*******@quakenet.org",
"Dr. Write"=>"wr***@writable.com"
);

echo "[";
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "{ name: \"$key\", to: \"$value\" }, ";
}
}
echo "]";

I want to create a test file that returns the following JSON:
[{"TagID":"017b253e-596b-4328-85f5-
fd97a783759c","Name":"Física","FileTags":[],"ProfessorTags":[]},
{"TagID":"3fae2160-55f6-4dd0-b856-
fd27f5d307e2","Name":"Matemática","FileTags":[],"ProfessorTags":[]},
{"TagID":"883b197e-0cb3-4528-8403-0877d742bf47","Name":"Matemática
B","FileTags":[],"ProfessorTags":[]},{"TagID":"f183cb9d-9d92-4c61-b03a-
e51cc1205b2b","Name":"Português","FileTags":[],"ProfessorTags":[]}]

I am not familiar with PHP and I need to create this to test
something.

Thanks,
Miguel

Jul 13 '08 #1
1 1292
shapper wrote:
Hi,

I have a file that returns JSON data:
<cut>
echo "[";
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "{ name: \"$key\", to: \"$value\" }, ";
}
}
echo "]";

I want to create a test file that returns the following JSON:

Look for json_encode and json_decode functions
Jul 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: G Matthew J | last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm This is more or less in response to Mr Crockford's admonition a few months ago, "fork if you must". Ironically, although in that usenet post...
20
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... ...
8
by: Douglas Crockford | last post by:
There is a new version of JSON.parse in JavaScript. It is vastly faster and smaller than the previous version. It uses a single call to eval to do the conversion, guarded by a single regexp test to...
2
by: Kevin Newman | last post by:
Hello, I noticed that the JavaScript library for JSON posted on json.org (http://www.json.org/json.js) is modifying Object.prototype (adding a method - toJSONString). I thought this was...
3
by: Adam | last post by:
I'm trying to retrieve some values from a json object, but instead it's giving me the property name. For example: var json = { "glossary": { "title": "example glossary" } }; console.log(json);...
2
by: ChrisO | last post by:
I've been pretty infatuated with JSON for some time now since "discovering" it a while back. (It's been there all along in JavaScript, but it was just never "noticed" or used by most until...
23
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns...
9
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
6
by: Lasse Reichstein Nielsen | last post by:
Max <adsl@tiscali.itwrites: Not really. It shows that a particularly naïve implementation of a conversion from XML to JSON doesn't work well. What if the conversion of <e> some
0
by: crocodilu2008 | last post by:
JSON vs. XML JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.