Funny thing with json_decode...
$ php
<?php echo var_export(json_decode("true ", true), true) ?>
NULL
(Press ctrl-d after you write "?>".)
The same using node.js:
| "use strict"; | |
| /** Query builder */ | |
| function build_query(type, schema) { | |
| // Metadata for builder | |
| var _converters = { | |
| js:{ | |
| or: function(x, y) { return '(' + x + ') || (' + y + ')'; }, | |
| and: function(x, y) { return '(' + x + ') && (' + y + ')'; }, |
| var http = require('http'); | |
| var options = { | |
| hostname: '192.168.56.101', | |
| port: 1337, | |
| path: '/', | |
| method: 'POST' | |
| }; | |
| var i = 0; |
| { | |
| "name": "promise-test", | |
| "version": "0.0.1", | |
| "description": "Promise test", | |
| "main": "test.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "repository": "", | |
| "author": "Jaakko-Heikki Heusala <jheusala@iki.fi>", |
| node_modules/ |
| var uri_builder = require('./uri.js'); | |
| var service_uri = uri_builder('http://api.example.com'); | |
| var collection_uri = service_uri('/users'); | |
| console.log(require('url').format(collection_uri)); |
| var Q = require('q'); | |
| var DB = require('db'); | |
| // These DB initializations would probably not be synchronous in a real | |
| // app. You could use Q.spread(), etc. See sample #2. | |
| var db1 = DB.openSync("db1"); | |
| var db2 = DB.openSync("db2"); | |
| var db3 = DB.openSync("db3"); |
| /** Get available objects for current user */ | |
| server.get('/', function(req, res, next) { | |
| var username = req.authorization.basic.username; | |
| db_query([ | |
| 'START root=node(0)', | |
| 'MATCH root-[:USERS_REF]->uroot-[:USER]->user-[:ACCEPT_READ]->n', | |
| 'WHERE user.name = {username}', | |
| 'RETURN n' | |
| ], {'username': username}).then(function(results) { | |
| var nodes = []; |
| /* $Id: account.js 13872 2010-08-23 11:42:51Z jheusala $ */ | |
| command.help.addSVN({ | |
| url:"$URL: https://svn.sendanor.fi/svn/sendanor/projects/ccd/server/trunk/commands/account.js $", | |
| author:"$Author: jheusala $", | |
| revision:"$Revision: 13872 $", | |
| date:"$Date: 2010-08-23 14:42:51 +0300 (Mon, 23 Aug 2010) $", | |
| id:"$Id: account.js 13872 2010-08-23 11:42:51Z jheusala $" | |
| }); |
Funny thing with json_decode...
$ php
<?php echo var_export(json_decode("true ", true), true) ?>
NULL
(Press ctrl-d after you write "?>".)
The same using node.js:
| mysql> SELECT * FROM freeciv_client_unitlog; | |
| +------------+---------------------+-----------+--------+--------+------------------+---------+--------------+---------+ | |
| | unitlog_id | created | unit_name | unit_x | unit_y | player_name | unit_hp | unit_veteran | unit_id | | |
| +------------+---------------------+-----------+--------+--------+------------------+---------+--------------+---------+ | |
| | 1 | 0000-00-00 00:00:00 | Trireme | 60 | 1 | Domenico Fattori | 10 | 0 | 164 | | |
| | 2 | 0000-00-00 00:00:00 | Trireme | 67 | 14 | Domenico Fattori | 10 | 1 | 397 | | |
| | 3 | 0000-00-00 00:00:00 | Trireme | 66 | 15 | Domenico Fattori | 10 | 1 | 397 | | |
| | 4 | 0000-00-00 00:00:00 | Trireme | 65 | 16 | Domenico Fattori | 10 | 1 | 397 | | |
| +------------+---------------------+-----------+--------+--------+------------------+---------+--------------+---------+ | |
| 4 rows in s |