Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42284 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13704 invoked from network); 16 Dec 2008 11:48:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2008 11:48:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.128.191 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.128.191 fk-out-0910.google.com Received: from [209.85.128.191] ([209.85.128.191:6852] helo=fk-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/FC-30437-49597494 for ; Tue, 16 Dec 2008 06:48:37 -0500 Received: by fk-out-0910.google.com with SMTP id 18so1854691fks.7 for ; Tue, 16 Dec 2008 03:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=yv/DdmaNEzMtnMjAn01fiGi/O0j0Tttp3t2V8y2kmtM=; b=KQvtWYUvu6ROAF6dydJVebVAmTua1zOCgA+IoCYcREbi/Idhdbwh2K+EWk0hzRIfVs dWKEBl4YgoK7LqGWWVX12XpjeheczeXWFJvJYwVYZU+wKFjoSzoGJO0f52EpcsOF9DjW 2I7prydp5gJWWlNJdRvjpXR/gXibXQ4RUK3iI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Ln7QX1AJkfmqMorxHBNd5fVFuEHwjRSHQANU7HliUSD7wf0kj7oUmXJ7AgYqLc08OI fmE+iSApn8ww+EUzLLYAGbbwW+qYT8CISJSCvMEtr8M2jutv1HdjM3mGZ0U+NhuIt8Cd wenBKx1GjIWyKW76kDTTZ0ddkCB4lnxglg3Ac= Received: by 10.103.1.5 with SMTP id d5mr3445732mui.29.1229428113944; Tue, 16 Dec 2008 03:48:33 -0800 (PST) Received: by 10.103.94.6 with HTTP; Tue, 16 Dec 2008 03:48:33 -0800 (PST) Message-ID: <10845a340812160348k18bffb0et1e75cf345b5e42cc@mail.gmail.com> Date: Tue, 16 Dec 2008 11:48:33 +0000 Reply-To: RQuadling@GoogleMail.com To: "PHP Developers Mailing List" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <494698D3.2030801@lerdorf.com> Subject: Re: [PHP-DEV] json_encode() From: rquadling@googlemail.com ("Richard Quadling") 2008/12/15 mike : > On Mon, Dec 15, 2008 at 9:50 AM, Rasmus Lerdorf wrote: > >> 1. Document the fact that if you want to strictly conform to the JSON >> spec and be sure your json_encode output will work in various JSON >> parsers, you have to pass it a PHP array or object. > > Instead of json_encode(34) the suggestion would be > json_encode(array(34)) ? Seems kind of like a lame thing to require. > IMHO the language should "do the right thing" as far as the consumer > (javascript/JSON parser) is concerned. However, Douglas is infinitely > more educated than I am here. This is just my $0.02 as a PHP user. I was one of those that read the PHP dox and not the RFC/standard (http://bugs.php.net/bug.php?id=38680). I would say that having PHP "correct" my mistake is wrong. If I say... json_encode(34); I am saying that I expect the result to be ... var i_SomeInt = 34; And from there I would expect to be able to say ... var i_SomeOtherInt = i_SomeInt + 10; This is not going to work if PHP "corrects" my mistake. I'd be perfectly happy for the standard to be enforced and an E_STRICT warning to be raised. If I want to shoot myself then I have to at least take the safety off first - turning off E_STRICT that is. Essentially, I don't like computers guessing my intent. If I don't state it clearly enough then it may be that I don't know what I'm doing. GIMGO (Garbage In, Maybe Garbage Out) isn't a good way to go. Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"