1: php 地址 http://127.0.0.6/؟c=json
2: جافا 输出的结果是
[{"id": 1 ، "name": "ZHDC"} ، {"id": 2 ، "name": "/u5c0f/u6731"}] index.php
<؟ phpif (isset ($ _ request ['c'])) {$ c = $ _request ['c'] ؛ if ($ c == "json") {$ arr = array (array ("id" => 1 ، "name" = "ZHDC") ، Array ("id" => 2 ، "name" => "小朱")) ؛ يموت (json_encode ($ arr)) ؛ }} main.class import java.io.bufferedInputStream ؛ import java.io.ioException ؛ import java.io.inputstream ؛ import java.io.inputstreamreader ؛ import java.io.riader ؛ import java.net.httpurlconnection ؛ import java.net.malformederled ؛ الفئة العامة الرئيسية {public static void main (string [] args) {try {url url = new url ("http://127.0.6/؟c=json") ؛ httpurlConnection httpurlConnection = (httpurlConnection) url.openconnection () ؛ httpurlconnection.setDoInput (صواب) ؛ httpurlconnection.connect () ؛ inputStream inputStream = httpurlConnection.getInputStream () ؛ BufferedInputStream BufferedInputStream = جديد BufferedInputStream (inputStream) ؛ reader reader = new inputStreamReader (bufferedInputStream) ؛ سلسلة json = "" ؛ int c ؛ بينما ((c = reader.read ())! = -1) {json += (char) c ؛ } system.out.println (json) ؛ } catch (malformedurlexception e) {// todo catch catch e.printstacktrace () ؛ } catch (ioException e) {// todo acto catch block e.printstacktrace () ؛ }}}