JSON字符串转JSON对象,注意其中desc中要两个,而不是一个

{ "title": "材料輸入","desc":{"處理內容":"","處理內容":""},"wf_type":{"處理內容":"1","處理內容":"1"},"point":{"處理內容":"80,400,250,300","處理內容":"80,300,250,350"},"wf_allowblank":{"處理內容":"N","處理內容":"N"},"wf_radio":{},"wf_radiopoint":{}}"

我试了JSON.parse和eval都不行,转化出来desc中都是一个

3个回答

gson格式是从js对象的基础延伸的,js对象键值对中的键需要保持唯一性,如果两个键完全相同,后者会覆盖前者。
如果只是为了从字符串中过去两个desc的值,就不要当成json串处理,直接使用正则替换出来

lovingning
lovingning 然后通过group(1)得到第一组匹配的内容;再通过split(‘,’)获取每一个键值对;如果desc数据只是单纯的键值对,没有成员对象,那么就可以获取desc的所有内容了
2 年多之前 回复
lovingning
lovingning 回复xxm0720: 先通过正则获取desc的值(不包含大括号):/"desc":{(.+)}/g
2 年多之前 回复
xxm0720
xxm0720 关键是desc重复的值不一定是“处理内容”
2 年多之前 回复

你这个应该是先拿desc 再拿"处理内容"里面的值,不知道这样行不行,我试试

xxm0720
xxm0720 关键是desc重复的值不一定是“处理内容”
2 年多之前 回复
                Gson gson = new Gson();
        JsonParser parser = new JsonParser();
        JsonObject obj = parser.parse(doGet).getAsJsonObject();
         int retCode = obj.get("ret_code").getAsInt();
        System.out.println("retCode=" + retCode);
        if (retCode == 200) {
         JsonArray dataArray = obj.get("data").getAsJsonArray();
        dataArray.forEach((action) -> {
         JsonObject dataObj = action.getAsJsonObject();
         int platformNo = dataObj.get("platform_no").getAsInt();
         System.out.println("platformNo=" + platformNo);
        });
        }
```那个doget就是掉第三方拿到的json数据

xxm0720
xxm0720 这个在哪里用,怎么感觉像是C#的代码?
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
解析json字符串 取出value值

我用JSON.stringify()方式把数据转换成json字符串,请问大神怎么把desc的值取出来 var obj={"desc":"my_test.department","child":[{"desc":"name2(string)","child":[]},{"desc":"count2(int)","child":[]}]};

c# 或者是js ,解析JSON格式的字符串

{ "title": "材料輸入","desc":{"處理內容":"","處理內容":""},"wf_type":{"處理內容":"1","處理內容":"1"},"point":{"處理內容":"80,400,250,300","處理內容":"80,300,250,350"},"wf_allowblank":{"處理內容":"N","處理內容":"N"},"wf_radio":{},"wf_radiopoint":{}}" 注意重复的内容不一定是“处理内容”,怎么获取desc和wf_radio中的值,注意用后desc中是要存值得,所以还要把它拼接起来

使用PHP脚本解析JSON数据字符串

<div class="post-text" itemprop="text"> <p>I have some json data that I would like to parse using PHP.</p> <p>I would like to extract:</p> <p>ID,NAME,DESC,ADDRESS (full),PHONE and HOURS.</p> <p>I have tried.</p> <pre><code>$json = json_encode( $value, true ); foreach($json['results'] as $result) { echo 'Title: ' . $result['general']['name'] . '&lt;br /&gt;'; } </code></pre> <p>but getting following error:</p> <pre><code>PHP Warning: Illegal string offset 'results' in ... PHP Warning: Invalid argument supplied for foreach() in .... </code></pre> <p>Here is the JSON data that I want to parse.</p> <pre><code>"ok":true, "query":"decarli", "page":0, "count":100, "total":1, "time":"2013-01-31 00:57:40", "results":[ { "id":"decarli-restaurant", "factualId":"f8990729-3ae7-4efa-8037-38fa899b07ea", "outOfBusiness":false, "publishedAt":"2012-03-09 10:35:51", "general":{ "name":"Decarli Restaurant", "timeZone":"EST", "desc":"Decarli is an ambitious restaurant created by Jana and Paul Decarli, a husband and wife team who along with their professional staff, are dedicated to food, wine, and providing an excellent dining experience. Paul, a longtime Oregonian and a graduate of Western Culinary Institute, developed his expertise at many of Portland\u00e2\u20ac\u2122s top restaurants including Paragon, Fratelli, Saucebox, and Tuscany Grill where he was Executive Chef. Jana, an Oregon native and University of Oregon graduate, established her outstanding service skills and standards at San Francisco\u00e2\u20ac\u2122s esteemed 42 Degrees and Portland\u00e2\u20ac\u2122s Bluehour. Decarli is committed to showcasing the state\u00e2\u20ac\u2122s considerable bounty of seasonal ingredients. Paul\u00e2\u20ac\u2122s culinary style draws on his Swiss\/Italian-American roots to create food that is at once sophisticated and rustic. The restaurant\u00e2\u20ac\u2122s interior reflects the couple\u00e2\u20ac\u2122s approach to food and wine\u00e2\u20ac\u201dwarm, inviting, thoughtful and authentic. The 4000 square foot space features restored Douglas Fir floors, exposed brick walls, and a soaring beam and rafters ceiling punctuated with skylights. A highlight of the dining room is a large brass chandelier salvaged from downtown Portland\u00e2\u20ac\u2122s historic Benson Hotel. An open kitchen overlooks the comfortable bar area. We invite you to join us soon.", "website":"http:\/\/decarlirestaurant.com" }, "location":{ "address1":"4545 SW Watson Ave", "address2":"", "city":"Beaverton", "region":"OR", "country":"US", "postcode":"97005", "longitude":-122.80611, "latitude":45.48648 }, "phones":{ "main":"503-641-3223", "fax":null }, "hours":{ "mon":{ "start":"closed", "end":"closed" }, "tue":{ "start":"04:30pm", "end":"10:00pm" }, "wed":{ "start":"04:30pm", "end":"10:00pm" }, "thu":{ "start":"04:30pm", "end":"10:00pm" }, "fri":{ "start":"04:30pm", "end":"11:00pm" }, "sat":{ "start":"04:30pm", "end":"11:00pm" }, "sun":{ "start":"05:00pm", "end":"09:00pm" }, "holidaySchedule":"" }, "businessType":"Restaurant" } ] } </code></pre> </div>

vb.net中如何解析Json数据?

vba 中解析json数据如下: ``` Sub VBA_Json() Dim JsonStr As String Dim SC As Object Dim AA, BB JsonStr = "{""desc"":""成功"",""dataa"":{""maxPage"":43522,""ppiUsername"":""谢文泽""}}" Set SC = CreateObject("ScriptControl") SC.Language = "JScript" Set AA = SC.Eval("eval(" & JsonStr & ")") Set BB = AA.dataa Debug.Print BB.maxPage '打印 43522 Debug.Print BB.ppiUsername '打印 谢文泽 End Sub ``` 现在在vb.net中,如何用Imports **Microsoft.JScript**解析上述json数据呢? vsto版本是2012版本。

ios关于用json转字典问题 ,请教

NSString *string1=@"{\"code\":\"1\",\"desc\":[{\"col_0007\":\"李玉华\", \"col_0023\":\"已回单\",\"col_0025\":\"800.00\", \"col_0027\":\"T14101400008\",\"col_0031\":\"2014-10-14 22:21:05\", \"col_0042\":\"null\",\"col_0057\":\"null\"},{\"col_0007\":\"李丽\", \"col_0023\":\"已转单\",\"col_0025\":\"0.00\", \"col_0027\":\"T14101400009\",\"col_0031\":\"2014-10-14 22:33:49\", \"col_0042\":\"null\",\"col_0057\":\"null\"}]}"; dicRoot = [[[SBJsonParser alloc]init] objectWithString:string1]; NSString *desc2 =[dicRoot objectForKey:@"desc"]; NSDictionary *dicRoot2 = [[[SBJsonParser alloc]init] objectWithString:desc2]; NSLog(@"sucahkshdkahskdjh: %@", dicRoot2); 报错 新手求教Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM dataUsingEncoding:]: unrecognized selector sent to instance 0x7a731320'

sql格式化和提取项目(json)

<div class="post-text" itemprop="text"> <p>So basically I should sum and list all products based on their name they should differ. This would work properly if I only selected the $[<em>]. item from the table but if I were to select all items with $[</em>]. I will get the following</p> <p>ROW: </p> <pre><code>[{"brand_name": "Product 1", "brand_id": "4", "quantity": 1}, {"brand_name": "Product 2", "brand_id": "5", "quantity": 3}] </code></pre> <p>RESULT:</p> <pre><code>{ "brand_id": "[\"4\", \"5\"]", "brand_name": "[\"Product 1\", \"Product 2\"]", "quantity": 0 } </code></pre> <p>EXPECTED RESULT:</p> <pre><code>{ "brand_id": "4", "brand_name": "Product 1", "quantity": 1 } { "brand_id": "5", "brand_name": "Product 2", "quantity": 3 } </code></pre> <p>QUERY ELOQUENT:</p> <pre><code>public function scopegetBasicMeans($query) { $query-&gt;where('type', 1) -&gt;join('report_asset', 'report_asset.report_id', '=', 'reports.id')-&gt;select( DB::raw('JSON_UNQUOTE(JSON_EXTRACT(resources, "$[*].name")) as brand_name'), DB::raw('JSON_UNQUOTE(JSON_EXTRACT(resources, "$[*].brand_id")) as brand_id'), DB::raw('SUM(JSON_EXTRACT(resources, "$[*].quantity")) as quantity') )-&gt;orderBy('quantity', 'DESC') -&gt;groupBy(DB::raw('JSON_EXTRACT(resources, "$[*].name")')); } </code></pre> <p>QUERY RAW:</p> <pre><code>select JSON_UNQUOTE(JSON_EXTRACT(resources, "$[*].name")) as brand_name, JSON_UNQUOTE(JSON_EXTRACT(resources, "$[*].brand_id")) as brand_id, SUM(JSON_EXTRACT(resources, "$[*].quantity")) as quantity, `reports`.`created_at`, `commercialist_id`, `type` from `reports` inner join `report_asset` on `report_asset`.`report_id` = `reports`.`id` where `reports`.`object_id` = ? and `reports`.`object_id` is not null and `type` = ? and `reports`.`deleted_at` is null group by JSON_EXTRACT(resources, "$[*].name") order by `quantity` desc </code></pre> <p>Basically I should sum the quality of all items with specific name and group them by their name which will get me the unique results. This would work if i were to select only first item from the table for example: $[0].name[0] but not on multiple. Any suggestions?</p> <p><a href="https://i.stack.imgur.com/AzQqG.png" rel="nofollow noreferrer">structure</a></p> </div>

JSON Unmarshal不规则JSON字段

<div class="post-text" itemprop="text"> <p>I have this code:</p> <pre><code>type Response struct { ID string `json:"id"` Tags Tags `json:"tags,omitempty"` } type Tags struct { Geo []string `json:"geo,omitempty"` Keyword []string `json:"keyword,omitempty"` Storm []string `json:"storm,omitempty"` } func (t *Tags) UnmarshalJSON(b []byte) (err error) { str := string(b) if str == "" { t = &amp;Tags{} return nil } err = json.Unmarshal(b, t) if err != nil { return err } return nil } </code></pre> <p>Now, my JSON response looks like this:</p> <pre><code>[{ "id": "/cms/v4/assets/en_US", "doc": [{ "id": "af02b41d-c2c5-48ec-9dbc-ceed693bdbac", "tags": { "geo": [ "DMA:US.740:US" ] } }, { "id": "6a90d9ed-7978-4c18-8e36-c01cf4260492", "tags": "" }, { "id": "32cfd045-98ac-408c-b464-c74e02466339", "tags": { "storm": [ "HARVEY - AL092017" ], "keyword": [ "hurrcane", "wunderground" ] } } ] }] </code></pre> <p>Preferably, I'd change the JSON response to be done correctly, but I cannot. Unmarshaling continues to error out (<code>goroutine stack exceeds 1000000000-byte limit</code>). Preferably, I'd rather do this using <a href="https://github.com/mailru/easyjson" rel="nofollow noreferrer">easyjson</a> or <a href="https://github.com/pquerna/ffjson" rel="nofollow noreferrer">ffjson</a> but doubt it is possible. Suggestions?</p> </div>

Ajax后台向前台传json或者string类型的数据,前台收到的数据都是object

前台代码: function pay(){ var map = new Map(); $.ajax({ type:"POST",//提交请求的方式 url:"/interface/servlet/paypay",//访问servlet的路径 dataType:"json",//没有这个,将把后台放会的json解析成字符串 data:$('#pay_submit').serialize(),//把内容序列化 async:true,//是否异步 error:function(data) {//请求出错 alert("出错"); }, success:function(data) {//获得返回值 console.log(data.allmap); alert(data.BUSI_DATA.ORDER_FEE); //var json =eval("("+data+")"); var bankForm = document.createElement("form"); bankForm.method = "post"; bankForm.action = "http://211.103.90.62:7061/payagent/PayUnifiedAccess"; bankForm.id = "IDataForm"; //var json = eval("("+map+")"); //for(var x in json){ var input = document.createElement("input"); input.id = "data"; input.name = "data"; input.type = "hidden"; //input.value ='{"PUB_INFO":{"BUSI_CODE":"1001","OS":"PC","VERIFY_CODE":"a902f90288e4fe8d6e2196499aa90f11b1efd98565f87ce14d9b39701e9d71794bde30a4269e69bd3caf3f754e5c6f9104c67abf207e869210979baf51ce7741f4831ee469e6c76c5828998b0f5d6febf3b95f7f9d9d23908beab2694c7279d52503498a6de5f2109ca68a43f89b3f7068892e29ab5bb34d739acb8fc3d71841"},"BUSI_DATA":{"ORDER_FEE":"1","GOODS_LIST":[{"TOTAL_MONEY":"1","GOODS_PRICE":"100","GOODS_NUM":"1","GOODS_NAME":"诺基亚","GOODS_ID":"0058812","GOODS_ITEM":"1"}],"PEER_TRADE_ID":"2017073011216092","ORDER_DESC":"陈小庆测试","MERCHANT_ID":"1517061200000251","ACCOUNT_CODE":"18322581301","VALID_TIME":"30"}}';// input.value = data; bankForm.appendChild(input); //} document.body.appendChild(bankForm); var submitAction = document.getElementById("IDataForm"); submitAction.submit(); } }); } 后台代码: protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { log.debug("================"); IData goodsInfo=new DataMap(); IDataset goodsList=new DatasetList(); DataMap pubInfo=new DataMap(); DataMap busiDataMap=new DataMap(); DataMap allMap=new DataMap(); goodsInfo.put("GOODS_ITEM", "1"); goodsInfo.put("GOODS_NAME", "诺基亚"); goodsInfo.put("GOODS_PRICE", "100"); goodsInfo.put("GOODS_NUM", "1"); goodsInfo.put("TOTAL_MONEY", "1"); goodsInfo.put("GOODS_ID", "0058812"); goodsInfo.put("TOTAL_MONEY", "1"); goodsList.add(goodsInfo); //goodsList.push(GOODS_LIST=goodsInfo); pubInfo.put("OS", "PC"); pubInfo.put("BUSI_CODE","1001"); busiDataMap.put("PEER_ORDER_ID","2017073011216092"); busiDataMap.put("ORDER_DESC","测试"); busiDataMap.put("ORDER_FEE","1"); busiDataMap.put("VALID_TIME","30"); busiDataMap.put("ACCOUNT_CODE","18322581301"); busiDataMap.put("MERCHANT_ID","1517061200000251");//商户号 busiDataMap.put("GOODS_LIST",goodsList);//商户号 allMap.put("PUB_INFO",pubInfo); allMap.put("BUSI_DATA",busiDataMap); log.debug(allMap); JSONObject json=JSONObject.fromObject(allMap); json.accumulate("data",allMap); req.setCharacterEncoding("utf-8"); resp.setCharacterEncoding("utf-8"); resp.setContentType("text/html"); PrintWriter out=resp.getWriter(); //out.print(JSON.toJSONString(json)); out.print(json.toString()); out.flush(); out.close(); } 后台代码中map包含多个集合,这些参数能直接以json形势传到前台整体取出来吗?求大神指教啊

JQGrid,如何将JSON字符串发布到PHP来处理并发送到数据库?

<div class="post-text" itemprop="text"> <p>Ok I have multiselected rows that I want to send to database onclick. Creates string of selected data rows and firebug shows they post. However I can't get it to post to the php and send to database as new entries. Please help.Also i would like to delete rows from database after sent to different table. Please i need help life and death.</p> <p>jqgrid[edit] Finally got it posting into the database. Only problem is that it posts each selection 7 times. I want it to post only one for each selection. Any help,please?</p> <pre><code>$(function(){ $("#list").jqGrid({ url:'request.php', editurl: "sendyo.php", datatype: 'xml', mtype: 'GET', multiselect:true, multiboxonly:true, height: 450, width: 850, colNames:['id','Project', 'Assigned To','Assign Date','Check Date','Due Date','Attachments'], colModel :[ {name:'id', index:'id', width:25}, {name:'name', index:'name', width:250, align:'left',editable:true, editoptions:{ size:60} }, {name:'id_continent', index:'id_continent', width:55, align:'right',editable:true,edittype:'select', editoptions:{value: "Henry:Henry; Ramon:Ramon; Paul:Paul" },mtype:'POST' }, {name:'lastvisit', index:'lastvisit', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y',editable:true, edittype: 'text',mtype:'POST' ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} , {name:'cdate', index:'cdate', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y', edittype: 'text',editable:true ,mtype:'POST' ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} , {name:'ddate', index:'ddate', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y',date:'true',editable:true, edittype: 'text',editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} , {name:'email', index:'email', width:70,align:'center',sortable:false,mtype:'POST' } ], pager: '#pager', rowNum:20, rowList:[20,40,80], sortname: 'id', sortorder: 'desc', viewrecords: true, gridview: true, caption: 'Pending Assignments', ondblClickRow: function(rowid) { $(this).jqGrid('editGridRow', rowid, {width:450,Height:400,recreateForm:true,closeAfterEdit:true, closeOnEscape:true,reloadAfterSubmit:false, modal:true,mtype:'post'});} }); jQuery("#minibutton").click( function(){ var selectedrows = $("#list").jqGrid('getGridParam','selarrrow'); if(selectedrows.length) { for(var i=0;i&lt;selectedrows.length; i++) { var selecteddatais = $("#list").jqGrid('getRowData',selectedrows[i]); var rows=JSON.stringify(selecteddatais) var postArray = {json:rows}; $.ajax({ type: "POST", url: "jsonsend.php", data: postArray, dataType: "json", error: function () { alert("An error occurred."); }, success: function (data) { } }); $( '#list' ).trigger( 'reloadGrid', [{ page: 1}] );//reload grid} }} }); }); </code></pre> <p></p> <p>PHP:</p> <pre><code> // connect to the MySQL database server $con = mysql_connect($dbhost, $dbuser, $dbpassword); if (!$con) { die('Could not connect: ' . mysql_error()); } @mysql_select_db($database,$con) or die("Error connecting to db."); //First decode the array $arr = $_POST["json"]; $decarr = json_decode($arr, true); $count = count($decarr); $values = array(); // This will hold our array values so we do one single insert for ($x=0; $x &lt; $count; $x++){ $newrec = $decarr; $id = $newrec['id']; $id = mysql_real_escape_string($id); $name = $newrec['name']; $name = mysql_real_escape_string($name); $id_continent = $newrec['id_continent']; $id_continent = mysql_real_escape_string($id_continent); $email = $newrec['email']; $email = mysql_real_escape_string($email); $lastvisit = $newrec['lastvisit']; $lastvisit = mysql_real_escape_string($lastvisit); $cdate = $newrec['cdate']; $cdate = mysql_real_escape_string($cdate); $ddate = $newrec['ddate']; $ddate = mysql_real_escape_string($ddate); // Create insert array $values[] = "('".$id."', '".$name."', '".$id_continent."', '".$lastvisit."','".$cdate."','".$ddate."','".$email."' )"; } // Insert the records $sql = "INSERT INTO finish (id, name, id_continent, lastvisit,cdate,ddate, email) VALUES ".implode(',', $values); $result = mysql_query($sql, $con) or die(mysql_error()); ?&gt; </code></pre> </div>

json_encode不编码长字符串

<div class="post-text" itemprop="text"> <p>in my script json_enocode is encoding string or there may be some other problem ?</p> <p>first Let me show all things that i have in my configuration and codes</p> <p>table structure</p> <pre><code>CREATE TABLE `dc_songs` ( `songs_id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `song_name` varchar(2000) NOT NULL, `lyrics` text NOT NULL, `created_time` datetime NOT NULL, `is_deleted` tinyint(4) NOT NULL, `delete_reason` text NOT NULL, PRIMARY KEY (`songs_id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 </code></pre> <p>Here is string that i have updated in one row of given table</p> <pre><code>UPDATE `dc_songs` SET `lyrics` = 'Your account privacy is very important to us. You are like our family member. You can manage all your content via privacy settings. Content with privacy settings public visible to every user of this web site. You must read how content will be displayed according to your privacy in Help Section. 2.Safety We do our best keep this web site safe but this not always depend on us, for that you will need to follow this safety Rules. You will not post content that is copyrighted or Unauthorized You will not use someone’s account You will not irritate users in anyways. You will not upload content like virus or spam. You will not share content that can hate someone, threatening, or pornographic. You will not do act that can affect this web site. You must provide all your original details. You will not use, download or share someone’s content like personal information, photographs, videos or any other that is not yours. You will not force user to do act that make our samaj down. You will not force user to fight against your enemy. You will not encourage people to do violence. You will not use this web site to do anything unlawful, misleading, malicious, or discriminatory. ' WHERE `dc_songs`.`songs_id` = 2; </code></pre> <p>query i am using </p> <pre><code>$query = "SELECT songs_id,lyrics,s.username,song_name,p.fullname FROM dc_songs s LEFT JOIN profile p ON p.username=s.username ORDER by songs_id DESC"; $r=$db-&gt;run($query); </code></pre> <p>after encoding $r i am getting this output</p> <p><strong>[{"songs_id":"2","lyrics":null,"username":"bhavik","song_name":"some name 1","fullname":"Bhavik Thakor Garasiya"}]</strong></p> <p><strong>UPDATE :</strong></p> <p>output of print_r($r);</p> <pre><code>Array ( [0] =&gt; Array ( [songs_id] =&gt; 2 [lyrics] =&gt; Your account privacy is very important to us. You are like our family member. You can manage all your content via privacy settings. Content with privacy settings public visible to every user of this web site. You must read how content will be displayed according to your privacy in Help Section. 2.Safety We do our best keep this web site safe but this not always depend on us, for that you will need to follow this safety Rules. You will not post content that is copyrighted or Unauthorized You will not use someone’s account You will not irritate users in anyways. You will not upload content like virus or spam. You will not share content that can hate someone, threatening, or pornographic. You will not do act that can affect this web site. You must provide all your original details. You will not use, download or share someone’s content like personal information, photographs, videos or any other that is not yours. You will not force user to do act that make our samaj down. You will not force user to fight against your enemy. You will not encourage people to do violence. You will not use this web site to do anything unlawful, misleading, malicious, or discriminatory. [username] =&gt; bhavik [song_name] =&gt; some name 1 [fullname] =&gt; Bhavik Thakor Garasiya ) ) </code></pre> </div>

php json_decode()不处理编码的JSON字符串。 解码值为NULL

<div class="post-text" itemprop="text"> <p>This JSON data has been subjected to 'JSON.stringify().replace()' ,then i'm trying to <code>json_decode()</code> in php in the backend. But it wont work.</p> <p>here is the program:</p> <pre><code> &lt;?php $a="{\\\"data\\\":{\\\"lab\\\":[\\\"a\\\",\\\"b\\\",\\\"c\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",\\\"9\\\",\\\"dd\\\"],\\\"stats\\\":{\\\"t1\\\":{\\\"name\\\":\\\"Tier Creation\\\",\\\"t_name\\\":\\\"dd\\\",\\\"t_desc\\\":\\\"dd\\\"},\\\"t_up\\\":{\\\"d_name\\\":\\\"T Up\\\",\\\"id\\\":4,\\\"up_t\\\":\\\"Li cases\\\",\\\"up_val\\\":[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",9],\\\"sm_temp\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"],\\\"ms_end_id\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"],\\\"short_check\\\":[\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\",\\\"0\\\"],\\\"e_sub\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"test\\\",\\\"\\\",\\\"sda\\\",\\\"\\\"],\\\"e_dy\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"&lt;p&gt;&amp;lt;title&amp;gt;&amp;lt;\\/title&amp;gt;\\\\\\\ &amp;lt;center&amp;gt;&amp;lt;img src=\\\\\\\\&amp;quot;clouds.jpg\\\\\\\\&amp;quot;\\/&amp;gt;&amp;lt;\\/center&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;hr\\/&amp;gt;\\\\\\\ &amp;lt;p&amp;gt;&amp;lt;a href=\\\\\\\\&amp;quot;http:\\/\\/somegreatsite.com\\\\\\\\&amp;quot;&amp;gt;LinkName&amp;lt;\\/a&amp;gt;isalinktoanotherniftysite&amp;lt;\\/p&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;h1&amp;gt;ThisisaHeader&amp;lt;\\/h1&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;h2&amp;gt;ThisisaMediumHeader&amp;lt;\\/h2&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;p&amp;gt;Sendmemailat&amp;lt;a href=\\\\\\\\&amp;quot;mailto:support@yourcompany.com\\\\\\\\&amp;quot;&amp;gt;support@yourcompany.com&amp;lt;\\/a&amp;gt;.&amp;lt;\\/p&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;p&amp;gt;Thisisanewparagraph!&amp;lt;\\/p&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Thisisanewparagraph!&amp;lt;\\/strong&amp;gt;&amp;lt;br\\/&amp;gt;\\\\\\\ &amp;lt;strong&amp;gt;&amp;lt;em&amp;gt;Thisisanewsentencewithoutaparagraphbreak,inbolditalics.&amp;lt;\\/em&amp;gt;&amp;lt;\\/strong&amp;gt;&amp;lt;\\/p&amp;gt;\\\\\\\ \\\\\\\ &amp;lt;hr\\/&amp;gt;\\\ \\\",\\\"\\\",\\\"&lt;p&gt;upgraded from {{initialname}} to {{name}} on&amp;nbsp; {{s_date}}\\\ \\\ &lt;p&gt;\\\\\\\ \\\\\\\ &amp;quot;,&amp;quot;\\\ \\\ &lt;p style=\\\"margin-left: 40px;\\\\\\\"&gt;{{name}} reached from{{initial_name}}on expiry date {{expiry_date}} name is {{full_name}}, first&amp;nbsp; {{first_name}} and last {{last_name}}\\\ \\\ &lt;p&gt;\\\\\\\ \\\\\\\ &amp;quot;,&amp;quot;\\\ \\\ &lt;p&gt;{{name}} from {{initial_name}} expires on {{expiry_date}} {{full_name}} and first {{first_name}} and last name {{last_name}}\\\ \\\ &lt;p&gt;\\\\\\\ \\\\\\\ \\\ \\\ &lt;p&gt;hi hello\\\ \\\",\\\"\\\"],\\\"t_id\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"],\\\"acc_id\\\":[\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\"]},\\\"aton\\\":{\\\"dime\\\":\\\"Po lcon\\\",\\\"grp\\\":{\\\"PRO\\\":{\\\"name\\\":\\\"PRO\\\",\\\"id\\\":2,\\\"a_type\\\":\\\"In terms of gg\\\",\\\"all\\\":[\\\"10.0\\\",\\\"20.0\\\",\\\"20.0\\\",\\\"100\\\",\\\"100\\\",\\\"100\\\",\\\"110\\\",\\\"100\\\",\\\"100\\\",100]},\\\"DEFAULT\\\":{\\\"name\\\":\\\"DEFAULT_ALL\\\",\\\"id\\\":3,\\\"al_type\\\":\\\"rated - In terms of gg\\\",\\\"alloc_val\\\":[\\\"100\\\",\\\"100\\\",\\\"100\\\",\\\"100\\\",\\\"100\\\",\\\"100\\\",\\\"120\\\",\\\"100\\\",\\\"100\\\",100]}}},\\\"finalize\\\":{\\\"lay_nam\\\":\\\"Fin\\\"}},\\\"curr_sym\\\":\\\"\\\"},\\\"ash_age\\\":\\\"\\\",\\\"log\\\":[]}"; $b = array(); $b=json_decode($a,"\0") or die("json decode unsuccessful "); echo ($b==NULL); echo print_r($b,true); ?&gt; </code></pre> <p>output: json decode unsuccessful</p> </div>

json数组包含另一个json数组的值 那么重叠部分li背景改变 求大神解决

这个是第一个json数组代表全部穴位; ``` var arr = eval(json[index].xuewei); var retStr = ","; $('#xueweiList').append( $(arr).map( function() { return '<li id=' + this.acupoint_num + '><a href="#" >' + this.name + '</a></li><li>' }).get().join('')); $("#nav>ul>li").click( function() { var focus = $(this).toggleClass('h_nav_over').hasClass( 'h_nav_over'); if (focus) retStr += this.id + ','; else retStr = retStr.replace(',' + this.id + ',', ','); $("#xueweis").val(retStr.replace(/^,|,$/g, '')); }); }); ``` ![图片说明](https://img-ask.csdn.net/upload/201607/20/1468980614_604330.png) 这是第二个json数组 疾病对应的穴位 ``` $.ajax({ type : "POST", url : "/miaolangzhong/manage/forAjax.do?requestType=6", data : "id=" + id, // 发送到服务器的数据 success : function(msg) { alert(msg); var json = eval('(' + msg + ')'); document.getElementById("addEd100").style.display = "block"; /* 获取后台传来的json是数组 循环获取数据 */ $.each(json, function(index, item) { document.getElementById("id1").value = json[index].id; document.getElementById("name1").value = json[index].name; document.getElementById("desc1").value = json[index].desc; /* 获取疾病对应穴位 */ var arr2 = eval(json[index].ear_acupoint); var arrStr2 = ''; $.each(arr2, function(index, item) { // 获取后台传来的json是数组 // 循环拼接字符串 // arrStr2 += arr2[index].earName; arrStr2 += "<input type='button' id='" + arr2[index].acupoint_num + "' value='" + arr2[index].earName + "' name='earName'/>"; }); // document.getElementById("earName1").value = arrStr2; var td2 = document.getElementById("xueweiTd2"); var div2 = document.getElementById("xuewei2"); div2.innerHTML = arrStr2; td2.appendChild(div2); ``` ![图片说明](https://img-ask.csdn.net/upload/201607/20/1468980616_305842.png) 这是js部分全部代码 ``` function updateEd100(id) { $.ajax({ type : "POST", url : "/miaolangzhong/manage/forAjax.do?requestType=6", data : "id=" + id, // 发送到服务器的数据 success : function(msg) { alert(msg); var json = eval('(' + msg + ')'); document.getElementById("addEd100").style.display = "block"; /* 获取后台传来的json是数组 循环获取数据 */ $.each(json, function(index, item) { document.getElementById("id1").value = json[index].id; document.getElementById("name1").value = json[index].name; document.getElementById("desc1").value = json[index].desc; /* 获取疾病对应穴位 */ var arr2 = eval(json[index].ear_acupoint); var arrStr2 = ''; $.each(arr2, function(index, item) { // 获取后台传来的json是数组 // 循环拼接字符串 // arrStr2 += arr2[index].earName; arrStr2 += "<input type='button' id='" + arr2[index].acupoint_num + "' value='" + arr2[index].earName + "' name='earName'/>"; }); // document.getElementById("earName1").value = arrStr2; var td2 = document.getElementById("xueweiTd2"); var div2 = document.getElementById("xuewei2"); div2.innerHTML = arrStr2; td2.appendChild(div2); /* 获取所有穴位 */ var arr = eval(json[index].xuewei); /* var arr = [ { "name" : "心", "id" : "1" }, { "name" : "肝", "id" : "2" }, { "name" : "脑袋", "id" : "3" }, { "name" : "屁股", "id" : "4" } ];*/ var retStr = ","; $('#xueweiList').append( $(arr).map( function() { return '<li id=' + this.acupoint_num + '><a href="#" >' + this.name + '</a></li><li>' }).get().join('')); $("#nav>ul>li").click( function() { var focus = $(this).toggleClass('h_nav_over').hasClass( 'h_nav_over'); if (focus) retStr += this.id + ','; else retStr = retStr.replace(',' + this.id + ',', ','); $("#xueweis").val(retStr.replace(/^,|,$/g, '')); }); }); } }); } ``` 这是本体 部分 ``` <tr> <td width="15%" nowrap align="right" height="100">对应的穴位:</td> <td colspan="3" id="xueweiTd2"><div id="xuewei2" class="h_nav_over"></div></td> </tr> <tr> <td width="15%" nowrap align="right" height="100">取穴:</td> <td colspan="3" id="xueweiTd"> <div id="nav"> <ul id="xueweiList"></ul> <input id="xueweis"> </div> </td> ``` **怎么实现 当第二个json数组元素和 第一个json数组元素 名字相同时 第二个数组背景变为红色** ![图片说明](https://img-ask.csdn.net/upload/201607/20/1468981692_916749.png)

前台解析Json串出错,求大神帮忙

``` { "obj": "[{\"contact_channel_detail\":\"5026789\",\"total_new_charge\":\"19.00\",\"total_due_amount\":\"0.00\",\"sum_latefee_amount\":\"0.00\",\"error\":\"0\",\"sum_wavelatefee_amount\":\"0.00\",\"error_message\":\"\",\"cust_name_full\":\"\",\"address_desc\":\"\",\"acct_prepay\":\"0.00\",\"payment_method_type\":\"\",\"arrearageQuery_info\":[[]]}]" } ```

json转译加斜杠,教教小弟急等,加一行就行

public static void main(String[] args) { { "\"visit_no"\":"\"16122200002"\", "\"visit_type"\": "\"2"\", "medicine_type": "11", "in_hosp_date": "2016-12-22", "card_no": "N54083048", "medical_dept_code": "", "medical_dept_name": "心肺病科", "doctor_code": "389", "doctor_name": "申艳", "pc_no": "", "patient_name": "马玉玉", "sex": "F", "age": "70", "birth_date": "1946-05-28", "id_no": "16122200002", "insurance_type": "1", "region_code": "R6403", "diagnoses": [ { "diagnose_no": "1", "diagnose_code": "J39.900", "diagnose_desc": "上呼吸道疾病" }, { "diagnose_no": "2", "diagnose_code": "", "diagnose_desc": "" } ], "advice_details": [ { "project_code": "90005687", "hospital_code": "61003487", "project_name": "八角茴香(复方)", "standard_code": "", "recipe_no": "0", "invoice_project": "61003487", "dose_form": "中药饮片", "medical_specification": "kg", "price": "0.098", "medical_number": "15", "dose_unit": "ml", "amount": "1.47", "self_pay_rate": "丁", "use_day": "1", "single_dose_number": "200", "single_dose_unit": "ml", "take_medical_number": "200", "take_medical_unit": "ml", "dose_day": "1", "deliver_way": "水煎服", "item_tag": "2", "take_frequence": "2/日" }, { "project_code": "90005687", "hospital_code": "61003487", "project_name": "xxxx)", "standard_code": "", "recipe_no": "0", "invoice_project": "61003487", "dose_form": "xxx片", "medical_specification": "kg", "price": "0.098", "medical_number": "15", "dose_unit": "ml", "amount": "1.47", "self_pay_rate": "丁", "use_day": "1", "single_dose_number": "200", "single_dose_unit": "ml", "take_medical_number": "200", "take_medical_unit": "ml", "dose_day": "1", "deliver_way": "水", "item_tag": "1", "take_frequence": "1/日" } ] } System.out.println(preProcess("原始报文")) ; }

需要修复Jquery错误:无效字符串JSON错误

<div class="post-text" itemprop="text"> <p>Trying to generate a piechart using dropdown menu and api but there is a json error for table showing invalid string. </p> <p>Pie file</p> <pre><code>&lt;?php $dbHost = 'localhost'; $dbUsername = 'root'; $dbPassword = ''; $dbName = 'techyari_demos'; // Create connection and select db $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName); ?&gt; &lt;html&gt; &lt;head&gt; &lt;!--Load the AJAX API--&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-1.9.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Load the Visualization API and the piechart,table package. google.load('visualization', '1', {'packages':['corechart','table']}); function drawItems(num) { var jsonPieChartData = $.ajax({ url: "getpiechartdata.php", data: "q="+num, dataType:"json", async: false }).responseText; var jsonTableData = $.ajax({ url: "gettabledata.php", data: "q="+num, dataType:"json", async: false }).responseText; // Create our data table out of JSON data loaded from server. var piechartdata = new google.visualization.DataTable(jsonPieChartData); var tabledata = new google.visualization.DataTable(jsonTableData); // Instantiate and draw our pie chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(piechartdata, { width: 700, height: 500, chartArea: { left:"5%",top:"5%",width:"90%",height:"90%" } }); // Instantiate and draw our table, passing in some options. var table = new google.visualization.Table(document.getElementById('table_div')); table.draw(tabledata, {showRowNumber: true, alternatingRowStyle: true}); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;select name="pt" onchange="drawItems(this.value)"&gt; &lt;option value=""&gt;Select a server:&lt;/option&gt; &lt;?php $dbHost = 'localhost'; $dbUsername = 'root'; $dbPassword = ''; $dbName = 'techyari_demos'; // Make a MySQL Connection $con = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName) or die(mysql_error()); mysqli_select_db($con,"techyari_demos") or die(mysqli_error()); // Create a Query $sql_query = "SELECT id, servername FROM server ORDER BY servername ASC"; // Execute query $result = mysqli_query($con,$sql_query) or die(mysqli_error()); while ($row = mysqli_fetch_array($result)){ echo '&lt;option value='. $row['id'] . '&gt;'. $row['servername'] . '&lt;/option&gt;'; } mysqli_close($con); ?&gt; &lt;/select&gt; &lt;/form&gt; &lt;div id="chart_div"&gt;&lt;/div&gt; &lt;div id="table_div"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>getpiechartdata </p> <pre><code>&lt;?php $q=$_GET["q"]; $dbHost = 'localhost'; $dbUsername = 'root'; $dbPassword = ''; $dbName = 'techyari_demos'; $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName); $sql_query="SELECT * from entry"; // $sql_query = "SELECT nickname, name, j2.label, j2.pointsum FROM user JOIN ( SELECT j1.user_id, j1.label, name, hover, j1.pointsum FROM activityfield JOIN ( SELECT user_id, activity_id, label, field_id , SUM( points.points ) AS PointSum FROM points JOIN activity ON points.activity_id = activity.id WHERE points.user_id=" . $q . " GROUP BY points.user_id, points.activity_id, activity.label, activity.field_id ORDER BY points.activity_id ASC ) AS j1 ON activityfield.id = j1.field_id ) AS j2 ON j2.user_id = user.id WHERE pointsum &gt; 0 ORDER BY j2.pointsum DESC;"; $con = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName)or die(mysql_error());; if (!$con){ die('Could not connect: ' .mysqli_error());} mysqli_select_db($con,"techyari_demos"); $result = mysqli_query($con,$sql_query); echo "{ \"cols\": [ {\"id\":\"\",\"label\":\"Name-Label\",\"pattern\":\"\",\"type\":\"string\"}, {\"id\":\"\",\"label\":\"PointSum\",\"pattern\":\"\",\"type\":\"number\"} ], \"rows\": [ "; $total_rows = mysqli_num_rows($result)or die(mysqli_error());; $row_num = 0; while($row = mysqli_fetch_array($result)){ $row_num++; if ($row_num == $total_rows){ echo "{\"c\":[{\"v\":\"" . $row['date'] . "-" . $row['sname'] . "\",\"f\":null},{\"v\":" . $row['status'] . ",\"f\":null}]}"; } else { echo "{\"c\":[{\"v\":\"" . $row['date'] . "-" . $row['sname'] . "\",\"f\":null},{\"v\":" . $row['status'] . ",\"f\":null}]}, "; } } echo " ] }"; mysqli_close($con); ?&gt; </code></pre> <p>gettabledata</p> <pre><code>&lt;?php $q=$_GET["q"]; $dbHost = 'localhost'; $dbUsername = 'root'; $dbPassword = ''; $dbName = 'techyari_demos'; $sql_query="SELECT date,sname,dbs,status,updatedby from entry"; $con = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName); if (!$con){ die('Could not connect: ' . mysql_error()); } mysqli_select_db($con,"techyari_demos"); $result = mysqli_query($con,$sql_query); echo "{\"c\":[{\"v\":\"" .'date'. "\",\"f\":null},{\"v\":\"" .'sname' . "\",\"f\":null},{\"v\":\"" .'dbs' . "\",\"f\":null},{\"v\":\"" .'status'. "\",\"f\":null},{\"v\":\"".'updatedby'."\",\"f\":null}]}, "; $total_rows = mysqli_num_rows($result); while($row = mysqli_fetch_array($result)){ echo "{\"c\":[{\"v\":\"" . $row['date'] . "\",\"f\":null},{\"v\":\"" . $row['sname'] . "\",\"f\":null},{\"v\":\"" . $row['dbs'] . "\",\"f\":null},{\"v\":\"" .$row['status']."\",\"f\":null},{\"v\":\"" . $row['updatedby']. "\",\"f\":null}]}, "; } /* $result = mysqli_query($sql_query2); while($row = mysqli_fetch_array($result)){ echo "{\"c\":[{\"v\":\"" . $row['servername'] . "\",\"f\":null},{\"v\":\"" . "\",\"f\":null},{\"v\":\"" . "\",\"f\":null},{\"v\":\" Total \",\"f\":null},{\"v\":\"" . $row['dbs'] . "\",\"f\":null}]}"; } echo " ] }";*/ mysqli_close($con); ?&gt; </code></pre> </div>

使用go中的字符串通过名称实例化结构

<div class="post-text" itemprop="text"> <p>I am trying to create a function that takes a <code>[]byte</code> and an <code>interface{}</code> (standing for the <code>struct</code>) and returns an <code>interface{}</code> as the <code>struct</code> type passed into the <code>func</code>. </p> <p>Something like this:</p> <pre><code>package main import ( "encoding/json" ) func UnmarshalFromJSONArray(sms []byte,tt string) (interface{}) { var ts = new(tt) err := json.Unmarshal(sms,&amp;ts) if(err != nil) { fmt.Println(err) } return sms } </code></pre> <p>So that method would run something like this:</p> <pre><code>// let's say a struct has the following definition: type MyStructType struct { Id int Name string Desc string } // we can some how get its fully qualified class name (this may require reflection?) or pass it into the UnMarshal method direction some how. mst := "package.MyStructType", // and then assume a byte array ba that has JSON format for ba := []byte(`{"Id":"3","Name":"Jack","Desc":"the man"}`) stct := UnmarshalFromJSONArray(ba,mst) MyStructureType out := stct // leaving "stct" being the unmarshalled byte array which can be used like any other struct of type "MyStructureType" </code></pre> <p>The key being that I never need to know what the fields of <code>MyStructureType</code> are before unmarshalling. All I need are the name of the <code>struct</code> and some way to instance one and then populate it with JSON byte array data that matches its fields. Hopefully that is possible (it is trivial in java using reflection). So I want to basically unmarshal an anonymous <code>struct</code> type by it's name without needing to know what fields it has.</p> <p>Any suggestions?</p> </div>

如何使用sqlx获取一片字符串?

<div class="post-text" itemprop="text"> <p>I am new to glang and I'd like to query Mysql using sqlx to get a slice of strings to be shipped as JSON. I know how to get the results like this:</p> <pre><code>type MediaURI struct { URI string `db:"uri" json:"uri"` } func MediaHandler(c *gin.Context) { var err error pid := c.PostForm("pid") var medias []MediaURI err = shared.Dbmap.Select(&amp;medias, "SELECT uri FROM media WHERE post_id = ? ORDER BY created_at DESC ", pid) if err != nil { log.Println(err) return } c.JSON(http.StatusOK, gin.H{"mediaUrls": medias}) } </code></pre> <p>But this gives a slice of structs like this:</p> <blockquote> <p>medias are:[{/media/photos/55/abc.png} {/media/photos/55/def.jpg} {/media/photos/55/gdx.png}]</p> </blockquote> <p>I'm wondering how can I directly get the strings? I've looked at the <a href="https://github.com/jmoiron/sqlx" rel="nofollow noreferrer">docs</a> but the answer (if there) is not clear to me.</p> </div>

在Facebook上分享一个字符串或部分页面

<div class="post-text" itemprop="text"> <p>I want to share a part of a page with Facebook ... this should be easy keeping in mind the scale of Facebook and the research that has been put into it. I have below loop which is fetching data from a $wpdb-&gt;select query and at the end of the loop I want a Facebook button but on click only that particular row of my MySQL table should be shared on Facebook. I know about <a href="https://developers.facebook.com/docs/plugins/share-button" rel="nofollow">https://developers.facebook.com/docs/plugins/share-button</a> to get the Facebook share code but how can I use this to share only the current value of my loop. Thanks any idea !! Below is my query and foreach loop ... I am not getting hold of it how this can be done.</p> <p>PHP Code</p> <pre><code>global $wpdb; $sqll = "SELECT articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title, SUBSTR(articles.body, 1, 512) As articlebody, articles.body, Sum(zvotes.zvotes) AS votessum FROM articles LEFT JOIN zvotes on articles.aid=zvotes.aid WHERE articles.category = '$cat' &amp;&amp; articles.competition = '$comp' GROUP BY articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title ORDER BY articles.aid DESC"; $results = $wpdb-&gt;get_results($sqll) or die(mysql_error()); $response=array(); if( is_array($results) &amp;&amp; count($results) &gt; 0 ) $form=""; foreach( $results as $result ) { $form.= '&lt;form id="voteform" action="" method="post"&gt;'; $form.= "&lt;input id='aid' name='aid' type='text' value='$result-&gt;aid'&gt;"; $form.= "&lt;div id='tsm'&gt;&lt;/div&gt;".'&lt;br&gt;'; $form.= "&lt;input id='category' name='category' type='hidden' value='$result-&gt;category'&gt;"; $form.= "Title :".$result-&gt;title.'&lt;br&gt;'; $form.= "&lt;div class='mg-image' style='margin-top:15px;'&gt;&lt;img id='articlecontest' src='$result-&gt;path' width='250' height='250' &gt;&lt;/div&gt;" . '&lt;br&gt;&lt;br&gt;'; $form.= "&lt;input id='competition' name='competition' type='hidden' value='$result-&gt;competition'&gt;"; $form.= "Username :".$result-&gt;username.'&lt;br&gt;'; $form.= "&lt;input id='sumofvotes' name='sumofvotes' type='hidden' value='$result-&gt;votessum'&gt;"; $form.= "&lt;div class='myvotes'&gt;&lt;div id='total'&gt;"."Total Votes:".$result-&gt;votessum."&lt;/div&gt;&lt;/div&gt;".'&lt;br&gt;'; $form.= "&lt;div id='articlesummary'&gt;".$result-&gt;articlebody."&lt;/div&gt;"; $form.="&lt;div id='clickme' style='color:blue; font-size:16px; font-family: Satisfy, Cursive;'&gt;".'READ MORE'."&lt;/div&gt;"; $form.= '&lt;div id="articlebody"&gt;'.'This is body text'.$result-&gt;body.'&lt;/div&gt;'; /////////////// $form.="&lt;input class='star' id='star1' type='image' type='submit' name='star5' src='http://localhost:8080/test/wp-content/uploads/2015/05/checkmark-small-unfilled.png' value='1' style='border:0px!important;'&gt;"; $form.="&lt;input class='star' id='star2' type='image' type='submit' name='star5' src='http://localhost:8080/test/wp-content/uploads/2015/05/checkmark-small-unfilled.png' value='2' style='border:0px!important;'&gt;"; $form.="&lt;input class='star' id='star3' type='image' type='submit' name='star5' src='http://localhost:8080/test/wp-content/uploads/2015/05/checkmark-small-unfilled.png' value='3' style='border:0px!important;'&gt;"; $form.="&lt;input class='star' id='star4' type='image' type='submit' name='star5' src='http://localhost:8080/test/wp-content/uploads/2015/05/checkmark-small-unfilled.png' value='4' style='border:0px!important;'&gt;"; $form.="&lt;input class='star' class='star' id='star5' type='image' type='submit' name='star5' src='http://localhost:8080/test/wp-content/uploads/2015/05/checkmark-small-unfilled.png' value='5' style='border:0px!important;'&gt;&lt;/form&gt;"; /////////////// }//end of foreach $response['form']=$form; echo json_encode($response['form']); exit(); } /////////////////////////////////// add_action( 'wp_ajax_star', 'star' ); add_action( 'wp_ajax_nopriv_star', 'star'); </code></pre> </div>

将微调器值转换为要在php中使用的字符串

<div class="post-text" itemprop="text"> <p><strong>Java file</strong></p> <pre><code>public class CreateScreen extends AppCompatActivity { EditText e1,e2,e3,e4,e5,e6,e7; Button b1,b2; Spinner s1,s2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); setContentView(R.layout.activity_create_screen); final Intent i = getIntent(); String vno = i.getStringExtra("vno"); String com = i.getStringExtra("com"); e1=(EditText)findViewById(R.id.editText8); e2=(EditText)findViewById(R.id.editText9); e3=(EditText)findViewById(R.id.editText10); e4=(EditText)findViewById(R.id.editText11); e5=(EditText)findViewById(R.id.editText12); e6=(EditText)findViewById(R.id.editText13); e7=(EditText)findViewById(R.id.editText14); e1.setText(vno); e2.setText(com); s1=(Spinner)findViewById(R.id.spinner); String[] items = new String[]{"RAW MATERIAL", "FINISHED MATERIAL", "SEMI FINISHED MATERIAL"}; ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_dropdown_item, items); s1.setAdapter(adapter); final String matgrp = adapter.toString(); s2=(Spinner)findViewById(R.id.spinner2); String[] item = new String[]{"INR", "USD", "MYR","JPY", "SGD"}; ArrayAdapter&lt;String&gt; adapter1 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_dropdown_item, item); s2.setAdapter(adapter1); final String currency = adapter1.toString(); b1=(Button)findViewById(R.id.save); b2=(Button)findViewById(R.id.home); b2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(CreateScreen.this,MaterialMenu.class); startActivity(i); } }); b1.setOnClickListener(new View.OnClickListener() { InputStream is =null; String result1 =null; @Override public void onClick(View v) { String a = e1.getText().toString(); String b = e2.getText().toString(); String c = e3.getText().toString(); String d = e4.getText().toString(); String z = e5.getText().toString(); String f = e6.getText().toString(); String g = e7.getText().toString(); ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("materialnumber", a)); nameValuePairs.add(new BasicNameValuePair("companycode", b)); nameValuePairs.add(new BasicNameValuePair("desc", c)); nameValuePairs.add(new BasicNameValuePair("mattype", matgrp)); nameValuePairs.add(new BasicNameValuePair("matgroup", d)); nameValuePairs.add(new BasicNameValuePair("baseunit", z)); nameValuePairs.add(new BasicNameValuePair("priceunit", f)); nameValuePairs.add(new BasicNameValuePair("orderunit", g)); nameValuePairs.add(new BasicNameValuePair("curr",currency)); try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://10.0.2.2/android/create.php"); httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); is = entity.getContent(); android.util.Log.e("log_tag", "connection success "); } catch (Exception e) { android.util.Log.e("log_tag", "Error in http connection " + e.toString()); Toast.makeText(getApplicationContext(), "Connection fail", Toast.LENGTH_SHORT).show(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + " "); } is.close(); result1 = sb.toString(); } catch (Exception e) { android.util.Log.e("log_tag", "Error converting result " + e.toString()); } try { JSONObject object = new JSONObject(result1); String w = object.getString("re"); if(w.equals("Material Created successfully")) { Toast.makeText(getApplicationContext(), w, Toast.LENGTH_SHORT).show(); Intent i = new Intent(CreateScreen.this, Menu.class); startActivity(i); } else { Toast.makeText(getApplicationContext(), w, Toast.LENGTH_SHORT).show(); } } catch (Exception e) { Log.e("log_tag", "Error parsing data "+e.toString()); Toast.makeText(getApplicationContext(), "JsonArray failed to load", Toast.LENGTH_SHORT).show(); } } }); } </code></pre> <p><strong>logcat</strong></p> <blockquote> <p>value cannot be converted to string</p> </blockquote> <p>How do I need to rewrite this code to convert the spinner value to a string to be used in JsonObject and in PHP?</p> </div>

C/C++学习指南全套教程

C/C++学习的全套教程,从基本语法,基本原理,到界面开发、网络开发、Linux开发、安全算法,应用尽用。由毕业于清华大学的业内人士执课,为C/C++编程爱好者的教程。

定量遥感中文版 梁顺林著 范闻捷译

这是梁顺林的定量遥感的中文版,由范闻捷等翻译的,是电子版PDF,解决了大家看英文费时费事的问题,希望大家下载看看,一定会有帮助的

YOLOv3目标检测实战:训练自己的数据集

YOLOv3是一种基于深度学习的端到端实时目标检测方法,以速度快见长。本课程将手把手地教大家使用labelImg标注和使用YOLOv3训练自己的数据集。课程分为三个小项目:足球目标检测(单目标检测)、梅西目标检测(单目标检测)、足球和梅西同时目标检测(两目标检测)。 本课程的YOLOv3使用Darknet,在Ubuntu系统上做项目演示。包括:安装Darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 Darknet是使用C语言实现的轻型开源深度学习框架,依赖少,可移植性好,值得深入探究。 除本课程《YOLOv3目标检测实战:训练自己的数据集》外,本人推出了有关YOLOv3目标检测的系列课程,请持续关注该系列的其它课程视频,包括: 《YOLOv3目标检测实战:交通标志识别》 《YOLOv3目标检测:原理与源码解析》 《YOLOv3目标检测:网络模型改进方法》 敬请关注并选择学习!

sql语句 异常 Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your

在我们开发的工程中,有时候会报 [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ------ 这种异常 不用多想,肯定是我们的sql语句出现问题,下面...

浪潮集团 往年的软件类 笔试题 比较详细的哦

浪潮集团 往年的软件类 笔试题 比较详细的哦

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

I2c串口通信实现加速度传感器和FPGA的交流

此代码能实现加速度传感器与FPGA之间的交流,从而测出运动物体的加速度。

Python可以这样学(第一季:Python内功修炼)

董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

eclipseme 1.7.9

eclipse 出了新的eclipseme插件,官方有下载,但特慢,我都下了大半天(可能自己网速差)。有急需要的朋友可以下哦。。。

Spring Boot -01- 快速入门篇(图文教程)

Spring Boot -01- 快速入门篇 今天开始不断整理 Spring Boot 2.0 版本学习笔记,大家可以在博客看到我的笔记,然后大家想看视频课程也可以到【慕课网】手机 app,去找【Spring Boot 2.0 深度实践】的课程,令人开心的是,课程完全免费! 什么是 Spring Boot? Spring Boot 是由 Pivotal 团队提供的全新框架。Spring Boot...

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

最简单的倍频verilog程序(Quartus II)

一个工程文件 几段简单的代码 一个输入一个输出(50Mhz倍频到100Mhz)

计算机组成原理实验教程

西北工业大学计算机组成原理实验课唐都仪器实验帮助,同实验指导书。分为运算器,存储器,控制器,模型计算机,输入输出系统5个章节

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

基于RSA通信密钥分发的加密通信

基于RSA通信密钥分发的加密通信,采用pycrypto中的RSA、AES模块实现

不同变质程度煤尘爆炸残留气体特征研究

为分析不同变质程度煤尘爆炸残留气体成分的特征规律,利用水平管道煤尘爆炸实验装置进行了贫瘦煤、肥煤、气煤、长焰煤4种不同变质程度的煤尘爆炸实验,研究了不同变质程度煤尘爆炸后气体残留物含量的差异,并对气体

设计模式(JAVA语言实现)--20种设计模式附带源码

课程亮点: 课程培训详细的笔记以及实例代码,让学员开始掌握设计模式知识点 课程内容: 工厂模式、桥接模式、组合模式、装饰器模式、外观模式、享元模式、原型模型、代理模式、单例模式、适配器模式 策略模式、模板方法模式、观察者模式、迭代器模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式 课程特色: 笔记设计模式,用笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 笔记以超链接形式让知识点关联起来,形式知识体系 采用先概念后实例再应用方式,知识点深入浅出 提供授课内容笔记作为课后复习以及工作备查工具 部分图表(电脑PC端查看):

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

几率大的Redis面试题(含答案)

本文的面试题如下: Redis 持久化机制 缓存雪崩、缓存穿透、缓存预热、缓存更新、缓存降级等问题 热点数据和冷数据是什么 Memcache与Redis的区别都有哪些? 单线程的redis为什么这么快 redis的数据类型,以及每种数据类型的使用场景,Redis 内部结构 redis的过期策略以及内存淘汰机制【~】 Redis 为什么是单线程的,优点 如何解决redis的并发竞争key问题 Red...

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化

jsp+servlet入门项目实例

jsp+servlet实现班级信息管理项目

winfrom中嵌套html,跟html的交互

winfrom中嵌套html,跟html的交互,源码就在里面一看就懂,很简单

Java面试题大全(2020版)

发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...

python实现数字水印添加与提取及鲁棒性测试(GUI,基于DCT,含测试图片)

由python写的GUI,可以实现数字水印的添加与提取,提取是根据添加系数的相关性,实现了盲提取。含有两种攻击测试方法(高斯低通滤波、高斯白噪声)。基于python2.7,watermark.py为主

Xshell6完美破解版,亲测可用

Xshell6破解版,亲测可用,分享给大家。直接解压即可使用

你连存活到JDK8中著名的Bug都不知道,我怎么敢给你加薪

CopyOnWriteArrayList.java和ArrayList.java,这2个类的构造函数,注释中有一句话 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public ArrayList(Collection&lt;? ...

相关热词 c# 不能序列化继承类 c# char* 调用 c# 开发dll模板 c#添加控件到工具箱 c#控制台组合数 编程计算猴子吃桃问题c# c# wpf 背景透明 随机抽取号码软件c# c# 开发环境 c# 属性和字段
立即提问