在我的代码中获取JSON Parser的错误

I am creating a registration form and sending data to MySql database through json in android but whenever i do click on submit button I got the following error in my logcat.

    12-19 18:19:22.145: E/JSON Parser(2620): Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
12-19 18:19:22.365: W/dalvikvm(2620): threadid=11: thread exiting with uncaught exception (group=0x40a13300)
12-19 18:19:22.865: E/AndroidRuntime(2620): FATAL EXCEPTION: AsyncTask #1
12-19 18:19:22.865: E/AndroidRuntime(2620): java.lang.RuntimeException: An error occured while executing doInBackground()
12-19 18:19:22.865: E/AndroidRuntime(2620):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.lang.Thread.run(Thread.java:856)
12-19 18:19:22.865: E/AndroidRuntime(2620): Caused by: java.lang.NullPointerException
12-19 18:19:22.865: E/AndroidRuntime(2620):     at app.restaurant.Register_Activity$RegisterUser.doInBackground(Register_Activity.java:162)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at app.restaurant.Register_Activity$RegisterUser.doInBackground(Register_Activity.java:1)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-19 18:19:22.865: E/AndroidRuntime(2620):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-19 18:19:22.865: E/AndroidRuntime(2620):     ... 5 more

This is my android code of registering form

Register_Activity.java

public class Register_Activity extends Activity {



//RadioGroup rg;

private ProgressDialog pDialog;
  // RadioButton rb;
 //  int id;

TextView nm,ad,ps,ph,em;
 String password;
    Button bnt_Submit;
    EditText edt_email,edt_password,edt_name,edt_phone,edt_address,edt_lastName;
    JSONObject json;

    JSONParser jsonParser = new JSONParser();

    private static String url_create_product = "http://192.168.1.9/adminfoodOld/public/jsonregister";

    //http://www.truzzinfotech.co.nz/admin/public/jsonregister


    private static final String TAG_SUCCESS = "success";



    //JSONArray phn,eml,pas,add,nam;
    String gender ="Male";
   @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register);

/*
     nm  = (TextView)findViewById(R.id.TXt_Name);
     em  = (TextView)findViewById(R.id.TXt_Email);
     ph  = (TextView)findViewById(R.id.TXt_Ph);
     ps  = (TextView)findViewById(R.id.TXt_password);
     ad  = (TextView)findViewById(R.id.TXt_Ad);

    */
    // rg = (RadioGroup)findViewById(R.id.radioGroup1);
    bnt_Submit =(Button)findViewById(R.id.btnsubmit);
    edt_email = (EditText)findViewById(R.id.Edt_Email);
    edt_password = (EditText)findViewById(R.id.Edt_Password);
    edt_name  = (EditText)findViewById(R.id.Edt_Name);
    edt_phone = (EditText)findViewById(R.id.Edt_Phone);
    edt_address = (EditText)findViewById(R.id.Edt_Address);
    edt_lastName = (EditText)findViewById(R.id.Edt_LastName);

/*   id = rg.getCheckedRadioButtonId();
      rb = (RadioButton)findViewById(id);*/
    bnt_Submit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            password = edt_password.getText().toString();
            if (!isValidPassword(password)) {
                edt_password.setError("The Passward must be at least 8 character ");
            }




              // Toast.makeText(getApplicationContext(), gender+"Selected", Toast.LENGTH_LONG).show();
            new RegisterUser().execute();



            }

    });

}


private boolean isValidPassword(String pass) {
    if (pass != null && pass.length() > 7) {
        return true;
    }
    return false;
}

class RegisterUser extends AsyncTask<String, String, String> {



    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();

        pDialog = new ProgressDialog(Register_Activity.this);
        pDialog.setMessage("Registering...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();


    }

    @Override
    protected String doInBackground(String... params) {

// TODO Auto-generated method stub
        //  gender= rb.getText().toString();

         String firstname =edt_name.getText().toString();
         String emails =edt_email.getText().toString();
         String phone =edt_phone.getText().toString();
         String address =edt_address.getText().toString();
         String lastname =edt_lastName.getText().toString();






     List<NameValuePair> params1 = new ArrayList<NameValuePair>();
     params1.add(new BasicNameValuePair("firstname", firstname));
     params1.add(new BasicNameValuePair("password", password));
     params1.add(new BasicNameValuePair("email", emails));
     params1.add(new BasicNameValuePair("phone", phone));
     params1.add(new BasicNameValuePair("address",address));
     params1.add(new BasicNameValuePair("gender", gender));
     params1.add(new BasicNameValuePair("lastname", lastname));
     Log.d("param",params1.toString());

 json = jsonParser.makeHttpRequest(url_create_product,"POST", params1);


     Log.d("Create Response", json.toString());

    /* Log.d("Gender", gender.toString());
     Log.d("name", firstname.toString());
     Log.d("pass", password.toString());
     Log.d("email", emails.toString());
     Log.d("lastname", lastname.toString());
     Log.d("address", address.toString());*/



     try {
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // successfully created product
            /*  Intent i = new Intent(getApplicationContext(), AllProductsActivity.class);
                startActivity(i);*/


            //  Toast.makeText(getApplicationContext(),"ravi kujaa", Toast.LENGTH_LONG).show();

                // closing this screen
                //finish();
            } else {
                // failed to create product



            }
     }catch (Exception e) {
                // TODO: handle exception
            }
    return null;





    }




    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();


                    /* try {


                            JSONObject json1 = json.getJSONObject("detail");




                    //   phn,eml,pas,add,nam;

                     phn = json1.optJSONArray("phone");
                     eml = json1.optJSONArray("email");
                     pas = json1.optJSONArray("password");
                     add = json1.optJSONArray("address");
                     nam = json1.optJSONArray("name");

                //  Log.d("Else_Part", json.toString());

                    Log.d("Name", nam.getString(0));
                    Log.d("Phone", phn.getString(0));
                    Log.d("Email", eml.getString(0));
                    Log.d("Password", pas.getString(0));
                    Log.d("Address", add.getString(0));


                    //edt_email,edt_password,edt_name,edt_phone,edt_address;
                    if(nam != null) {
                        nm.setText(nam.getString(0));
                        }

                        if(eml!= null ){
                        em.setText(eml.getString(0));
                        }
                        if(phn!= null ){
                        ph.setText(phn.getString(0));
                        }
                        if(pas!= null ){
                        ps.setText(pas.getString(0));
                        }
                        if(add!= null ){
                        ad.setText(add.getString(0));
                        }





                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                */



        }




    }

}

This is my php code result encoded in json

{"detail":{"email":["The email field is required."],"password":["The password field is required."],"firstname":["The firstname field is required."],"lastname":["The lastname field is required."],"phone":["The phone field is required."],"address":["The address field is required."]},"success":0}

This is my Php file

<?php

class FrontUserController extends \BaseController {

    /**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function index()
{

    if(controllerAssignView('frontuser'))      
    {

    $frontuser = frontuser::all();

    return View::make('admin.registered')->with('data', $frontuser);
    }
    else
    {
            return Redirect::to('index');
    }
}


    public function jsonregister()
{

        $inputs = Input::all();
        $validator = Validator::make(
            array(
                'email' => $inputs['email'],
                'password' => $inputs['password'],
                'firstname' => $inputs['firstname'],
                'lastname' => $inputs['lastname'],
                'phone' => $inputs['phone'],
                'address' => $inputs['address']

            ),
            array(
                'email' => 'required|email|unique:frontuser',
                'password' => 'required|min:8',
                'firstname' => 'required',
                'lastname' => 'required',
                'phone' => 'required|numeric',
                'address' => 'required'

            )
        );
    if ($validator->fails())
        {
            $messages = $validator->messages();
            $userDetail = array();
            $userDetail['detail'] = $messages;
            $userDetail['success'] = 0;
            return $userDetail;
        }
        else
        {

                $Frontuser = new frontuser;
                $Frontuser->email = $inputs['email'];
                $Frontuser->password =  Hash::make($inputs['password']);
                $Frontuser->firstname = $inputs['firstname'];
                $Frontuser->lastname = $inputs['lastname'];
                $Frontuser->phone = $inputs['phone'];
                $Frontuser->address = $inputs['address'];
                $Frontuser->status = $inputs['active'];
                $Frontuser->gender = $inputs['gender'];
                if($inputs['type'] != 'null'){$Frontuser->$inputs['type'] =1;}

                $Frontuser->save();

                $user = frontuser::where('email', '=', $inputs['email'])->take(1)->get();


                    $userDetail = array();
                    $userDetail['detail']['firstname'] = $user[0]->firstname;
                    $userDetail['detail']['lastname'] = $user[0]->lastname;
                    $userDetail['detail']['gender'] = $user[0]->gender;
                    $userDetail['detail']['phone'] = $user[0]->phone;
                    $userDetail['detail']['address'] = $user[0]->address;
                    if($user[0]->facebook == 1){$userDetail['detail']['login'] = 'registered with facebook.';}
                    if($user[0]->twitter == 1){$userDetail['detail']['login'] = 'registered with twitter.';}
                    if($user[0]->googleplus == 1){$userDetail['detail']['login'] = 'registered with googleplus.';}
                    $userDetail['success'] = 1;
                    return $userDetail;

        }
    }

?>

doushi1957
doushi1957 您是否使用RESTClient测试了URL
5 年多之前 回复
douzhong3887
douzhong3887 我刚刚在我的问题中更新了我的PHP代码,请你检查它是否正确
5 年多之前 回复
doupai6875
doupai6875 可能,不一定。如果PHP抛出异常或产生通知,那么当然会导致无效的JSON,但很可能你没有在你的响应中设置正确的标题(参见我的回答)
5 年多之前 回复
dongliang9576
dongliang9576 所以你的意思是PHP代码中存在错误
5 年多之前 回复
dongxian5735
dongxian5735 这是排队的。162Log.d(“CreateResponse”,json.toString());
5 年多之前 回复
douba4933
douba4933 更仔细地查看错误消息:“<!DOCTYPE类型java.lang.String不能......”。PHP没有像你在这里发布的那样返回一个JSON字符串,它返回一个标记页面,从<!DOCTYPE>开始,依此类推,这当然是无效的JSON
5 年多之前 回复
dream2891
dream2891 你得到nullpointer异常,所以请显示行Register_Activity.java:162行
5 年多之前 回复

1个回答



重要</ strong>:</ p>

以下答案介绍如何确保 发送了正确的标头,但只有在您的代码本身不包含任何错误时才能使用。 但是,您的代码确实存在一些需要尽快解决的问题:</ p>

  $ userDetail = array(); 
$ userDetail ['detail'] ['firstname' ] = $ user [0] - &gt; firstname;
</ code> </ pre>

此声明 将</ em> </ strong>发出通知( undefined offset),因为 $ userDetail </ code>被初始化为空数组(1D),然后用作2D关联数组。 如果php.ini设置为 E_STRICT | E_ALL </ code>这将(正确地)生成通知。 修复它:</ p>

  $ userDetail = array('detail'=&gt; array()); 
</ code> </ pre>

如果您不确定代码为何会产生此通知,请我在此解释了这一点 </ p>
\ n


您正在调用的PHP脚本未生成纯JSON字符串。 异常消息告诉您字符串的值以&lt;!DOCTYPE </ code>开头。 您需要在PHP中添加相应的标头,方法是将其添加到脚本中(在最上面,在此之前不能发送任何输出):</ p>

 &lt;  ?php //在这个开始标记之前,甚至不允许空格!
header('Content-Type:application / json');
$ data = ['get'=&gt; 'data','here'];
echo json_encode($ data);
</ code> </ pre>

当然,如果PHP脚本包含错误(通知,未捕获的异常等) ..),那么输出就会搞砸了。 彻底调试脚本,也许通过将 json.toString()</ code>打印(或写入)到日志或tmp文件来检查Java中的响应是什么</ p>

更新:</ em> </ p>

看起来您正在使用PHP框架(很可能是Laravel)。 检查该框架的文档,看看它是否没有为您处理JSON响应的响应组件。 如果您正在使用Laravel,操作应该返回如下:</ p>

 返回Response :: json($ userDetail); 
</ code> </ pre> \ n

参见 Laravel文档 </ p>
</ div>

展开原文

原文

Important:

The answer below deals with how to ensure the correct headers are sent, but this can only work if your code itself doesn't contain any errors. Your code, however, does have some issues that need to be addressed ASAP:

$userDetail = array();
$userDetail['detail']['firstname'] = $user[0]->firstname;

This statement will produce a notice (undefined offset), because $userDetail is initialized to an empty array (1D), and then used as a 2D associative array. If php.ini is set to E_STRICT | E_ALL this will (rightfully) generate a notice. Fix it:

$userDetail = array('detail' => array());

If you're unsure as to why your code produces this notice I've explained this here


The PHP script you're calling isn't generating a pure JSON string. The exception message tells you the string's value starts with a <!DOCTYPE. You'll need to set the appropriate headers in PHP by adding this to your script (at the very top, no output can be sent prior to this point):

<?php //before this opening tag, not even a space is allowed!
header('Content-Type: application/json');
$data = ['get' => 'data', 'here'];
echo json_encode($data);

Of course, if the PHP script contains errors (notices, uncaught exceptions etc...), then the output will be messed up because of that. Debug the script thoroughly, and perhaps check what the response looks like in Java by printing (or writing) json.toString() to a log or tmp file

Update:

It looks like you're using a PHP framework (Laravel most likely). Check that framework's docs to see if it doesn't have a response component that handles JSON responses for you. In case you're using Laravel, the action should return like so:

return Response::json($userDetail);

cf Laravel documentation

duanbing2963
duanbing2963 谢谢回答
5 年多之前 回复
douyin9987
douyin9987 我正在使用laravel mvc。 这么晚才回复很抱歉
5 年多之前 回复
douyi6290
douyi6290 更新了我的答案,因为您的代码包含需要修复的错误才能使其工作(未定义的偏移通知将发送标题)
5 年多之前 回复
drrhr20884
drrhr20884 更新您的问题,告诉我们您正在使用的框架
5 年多之前 回复
dongzhou5344
dongzhou5344 这是对一般问题的正确答案。 @typing ....好像你正在使用PHP框架。 您可以检查框架是否提供仅返回json数据的函数。 否则,框架可能会将结果包装在HTML框架中
5 年多之前 回复
dongqixian8474
dongqixian8474 我刚刚在我的问题中更新了我的PHP代码,请你检查它是否正确
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
验证JSON并显示错误位置

<div class="post-text" itemprop="text"> <p>I want to parse and validate (custom) JSON configuration files within Go. I would like to be able to parse the file into a struct and validate that:</p> <ol> <li>no unexpected keys are present in the JSON file (in particular to detect typos)</li> <li>certain keys are present and have non-empty values</li> </ol> <p>In case the validation fails (or in case of a syntax error), I want to print an error message to the user that explains as detailed as possible where in the file the error happened (e.g. by stating the line number if possible).</p> <p>The JSON parser built into Go seems to just silently ignore unexpected keys. I also tried using jsonpb (Protobuf) to deserialize the JSON, which returns an error in case of an unexpected key, but does not report the position.</p> <p>To check for non-empty values, I could use an existing validation library, but I haven't seen any does reports detailed error messages. Alternatively, I could write custom code that validates the data returned by the built-in JSON parser, but it would be nice if there was a generic way.</p> <p>Is there a simple way to get the desired behaviour?</p> </div>

在Wordpress中使用JSON的Ajax parsererror

<div class="post-text" itemprop="text"> <p>I'm doing an application web for a school and I'm stuck when trying to edit a student. I want the user to click in the row of and specific student and then open a form with his data. </p> <p>I have to do an ajax request, so I can call my php function (the one which makes the query on my db) and load the data in the form. This is my jQuery code for the ajax request: </p> <pre><code>//When you click in the table students, in some element whose class is edit ... $("#tblAlumnos").on("click", ".editar", function(event) { var rowID = $(this).parents('tr').attr('id'); $.ajax({ type: 'POST', url: '../ajax/', data: {'table': 'alumnos', 'action': 'carga', 'ids': rowID}, dataType: 'json', success: function(result) { console.log(result.nombre); }, error: function (jqXHR, exception) { if (jqXHR.status === 0) { alert('Not connect. Verify Network.'); } else if (jqXHR.status == 404) { alert('Requested page not found. [404]'); } else if (jqXHR.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); alert(jqXHR.status); alert(jqXHR); } else if (exception === 'timeout') { alert('Time out error.'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Uncaught Error. ' + jqXHR.responseText); } } }); }); </code></pre> <p>The ajax request calls the method to get the data from my db:</p> <pre><code>function cargaAlumno($ids) { require 'db.php'; $sql = "SELECT * FROM Alumnos WHERE ID=$ids"; $result = $conexion-&gt;query($sql); if ($result-&gt;num_rows &gt; 0) { $row = $result -&gt; fetch_assoc(); $nombre = $row['Nombre']; $apellidos = $row['Apellidos']; $telefono = $row['Telefono']; $usuario = $row['Usuario']; $contrasena = $row['Contrasena']; $result = array(); $result["nombre"] = $nombre; $result["apellidos"] = $apellidos; $result["telefono"] = $telefono; $result["usuario"] = $usuario; $result["contrasena"] = $contrasena; ChromePhp::warn($result); ChromePhp::warn(json_encode($result)); echo json_encode($result); } } </code></pre> <p>This method has to return a JSON to the ajax request, but the success method is never reached because of the error: parsererror. </p> <p>I've tried with dataType: 'json' (this is when I have the error) and without it (it thinks its html). I also have tried with and without contentType and in my php: header('Content-type: application/json; charset=utf-8'). </p> <p>My json encoded looks like this:</p> <pre><code>{"nombre":"Susana","telefono":"56765336","usuario":"susa"} </code></pre> <p>I don't know if I need some more methods because I'm doing it in Wordpress or I have something wrong in my code. </p> <p>Any help would be appreciated. Thank you in advance :)</p> </div>

parsererror SyntaxError:JSON输入的意外结束

<div class="post-text" itemprop="text"> <p>When I add <code>if(isset($_POST['uplprofimg']))</code>, I get the error:</p> <pre><code>parsererror SyntaxError: Unexpected end of JSON input </code></pre> <p>If I exclude the php if isset post function, the code works perfectly.</p> <p>So, PHP:</p> <pre><code>if(isset($_POST['uplprofimg'])){ //← This if broke my code &gt;:( //Works if I remove the ↑ if($_FILES['imagefile']['size'] &gt; 5242880){ $ress = "&lt;div class='error'&gt;Max file size is 5MB&lt;/div&gt;"; echo json_encode(array('response' =&gt; false,'ress' =&gt; $ress)); }else{ $imgtype = pathinfo($_FILES['imagefile']['name'],PATHINFO_EXTENSION); if(!in_array($imgtype,array('jpg','jpeg','png','gif'))){ $ress = "&lt;div class='error'&gt;Only &lt;b&gt;jpg&lt;/b&gt;, &lt;b&gt;jpeg&lt;/b&gt;, &lt;b&gt;png&lt;/b&gt; and &lt;b&gt;gif&lt;/b&gt; files are allowed (".$imgtype.")&lt;/div&gt;"; echo json_encode(array('response' =&gt; false,'ress' =&gt; $ress)); }else{ $newimgname = "/profile_picture/".random_num($length = 8).time().random_num($length = 8).".".$imgtype; $newimgnameserv = $_SERVER['DOCUMENT_ROOT'].$newimgname; if(move_uploaded_file($_FILES['imagefile']['tmp_name'],$newimgnameserv)){ $upuser = $mysqli-&gt;prepare('UPDATE accinfo SET profilepic = ? WHERE username = ?'); $upuser-&gt;bind_param('ss',$newimgname,$username); $check = $upuser-&gt;execute(); if($check == true){ echo json_encode(array('response' =&gt; true)); }else{ $ress = "&lt;div class='error'&gt;SQL Error&lt;/div&gt;"; echo json_encode(array('response' =&gt; false,'ress' =&gt; $ress)); } }else{ $ress = "&lt;div class='error'&gt;Couldn't move the file. Please try again later.(".$newimgname.")&lt;/div&gt;"; echo json_encode(array('response' =&gt; false,'ress' =&gt; $ress)); } } } } </code></pre> <p>and JS:</p> <pre><code>$("#uploadimgform").on("submit",function(event){ event.preventDefault(); var formData = new FormData(this); $("#uploadlistener").html("&lt;img src='/images/load.gif' width='50px' /&gt;"); $.ajax({ type: 'POST', url: "/system/requests.php", data: formData, dataType: "json", cache: false, contentType: false, processData: false, success: function(data){ if(data.response === true){ $("#bodyfader").fadeOut("slow"); $("#expandedupl").fadeOut("slow"); $("#uploadlistener").html(""); }else{ $("#uploadlistener").html(data.ress); $('#profilepic').css('background', 'url(/images/defaultprof.png)'); $("#profilepic").css("background-size","cover"); $("#profilepic").css("background-position","center"); } }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); }); </code></pre> <p>If I remove the <code>if(isset($_POST['uplprofimg'])){...}</code>, the code works. But if I add it there, I get the json error. What is going on?</p> <p>HTML Form:</p> <pre><code>&lt;form method='POST' enctype="multipart/form-data" id='uploadimgform' style='display: none;'&gt; &lt;input type='file' id='upload' name='imagefile' accept="image/x-png,image/gif,image/jpeg" /&gt; &lt;input type='submit' id='uploadconf' name='uplprofimg' /&gt; &lt;/form&gt; </code></pre> <p>This is how the form is submitted:</p> <pre><code>$("#upload").change(function(){ if(this.files[0].size &gt; 5242880){ $("#uploadlistener").html("&lt;div class='error'&gt;Maximum file size is 5MB.&lt;/div&gt;"); $("#upload").val(""); }else{ $("#uploadimgform").submit(); readURL(this); } }); </code></pre> <p>I have no idea why, but I did this:</p> <pre><code>formData.append('uplprofimg',1); </code></pre> <p>and the code works. Someone can explain this?</p> </div>

求助,python 解析爬取的网页源码中的json部分

爬下来的网页源码有一部分是这样的 : ![图片说明](https://img-ask.csdn.net/upload/201603/11/1457684608_605734.jpg) 中间那一部分是json吧?要怎么才能解析成像浏览器那样的好继续抓取所要的信息? 说部分是因为有另外一些是正常的html,就中间这一部分想要的信息就这样两行超级长的延伸。。。也使用过json.load()来解析,不想显示错误“没有可以解析的json对象”。 这两行中还有一部分“}\u0026nick\u003d${nick}\u0026rn\u003d${rn}\u0026stats...”应该是unicode的编码,也不知道要怎么办。。 我是想要从淘宝上爬些衣服的图片下来,从首页开始,爬出其中分页的链接,然后拿到分页的源码后要解析出图片的url时出的问题。 下面是部分代码: url = 'https://www.taobao.com' header = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'} cookie = {"cookies":'mt="ci=10_1";uc1="cookie14=UoWyia%2Bf0iS5lw%3D%3D&cookie16=VT5L2FSpNgq6fDudInPRgavC%2BQ%3D%3D&existShop=false&cookie21=U%2BGCWk%2F7pY%2FF&tag=7&cookie15=UIHiLt3xD8xYTw%3D%3D&pas=0"'} html = requests.get(url) #解析html,xml转义字符 html_parser = HTMLParser.HTMLParser() text = html_parser.unescape(html.text) # soup = BeautifulSoup(html.text) #用xpath来提取链接,如"打底羊毛衫"这个类别 selector = etree.HTML(text) sub_url = selector.xpath('//*[@id="J_Top"]/div/div[1]/div/div/div/div[3]/div[1]/div/div/div[1]/a[1]/@href') print sub_url[0] sub_html = requests.get(sub_url[0]) sub_text = html_parser.unescape(sub_html.text) # soup = BeautifulSoup(sub_html.text,"lxml") # print soup.prettify() print sub_text ``` ```

iOS json parser 解析字符串

( { address = "xx-xx-xxxx,x - street, x - country"; email = "ravi@gmail.com"; gender = male; id = c200; name = "Ravi Tamada"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "johnny_depp@gmail.com"; gender = male; id = c201; name = "Johnny Depp"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "leonardo_dicaprio@gmail.com"; gender = male; id = c202; name = "Leonardo Dicaprio"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "john_wayne@gmail.com"; gender = male; id = c203; name = "John Wayne"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "angelina_jolie@gmail.com"; gender = female; id = c204; name = "Angelina Jolie"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "dido@gmail.com"; gender = female; id = c205; name = Dido; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "adele@gmail.com"; gender = female; id = c206; name = Adele; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "hugh_jackman@gmail.com"; gender = male; id = c207; name = "Hugh Jackman"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "will_smith@gmail.com"; gender = male; id = c208; name = "Will Smith"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "clint_eastwood@gmail.com"; gender = male; id = c209; name = "Clint Eastwood"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "barack_obama@gmail.com"; gender = male; id = c2010; name = "Barack Obama"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "kate_winslet@gmail.com"; gender = female; id = c2011; name = "Kate Winslet"; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; }, { address = "xx-xx-xxxx,x - street, x - country"; email = "eminem@gmail.com"; gender = male; id = c2012; name = Eminem; phone = { home = "00 000000"; mobile = "+91 0000000000"; office = "00 000000"; }; } ) 如何解析上面这些数据解析成数据字典的格式

在golang中构造复杂的JSON解析

<div class="post-text" itemprop="text"> <p>I have a valid JSON, which I don't know how to parse in json.Unmarshal (golang):</p> <pre><code>{ "method": "notice", "params": [0, [{ "previous": "12345", "timestamp": "2017-12-12T05:49:09", "witness": "12345", "transaction_merkle_root": "ffff", "extensions": [], "witness_signature": "12345" }]] } </code></pre> <p>All I can do is:</p> <pre><code>type MyJSON struct { Method string `json:"method"` Params []interface{} `json:"params"` } </code></pre> <p>I will be really thankful if somebody help me to write correct MyJSON type to parse all other fields through golang's json.Unmarshal. It's way too complex to me :(</p> </div>

如何删除parsererror:SyntaxError:位于0的JSON中的意外标记<

<div class="post-text" itemprop="text"> <p>I am trying to fetch data from MySQL Database using PHP and passing it on as JSON. When I try to display the response, it displays the error parsererror: SyntaxError: Unexpected token &lt; in JSON at position 0. Can someone please help. Below is my jQuery and PHP Code:</p> <p><strong>jQuery:</strong></p> <pre><code>$(document).ready(function() { $("#display").change(function() { var type = document.getElementById('display').value; alert(type); $.ajax( { //create an ajax request to load_page.php type: "GET", url: "DBOperations.php", data : "type=" +type, dataType: "json", //expect text to be returned success: function(response) { //$("#response").html(response); //alert(response.); $.each(response, function(index, element) { $('#response').html($( { text: element.name })); }); }, error: function(jqXHR, textStatus, errorThrown) { alert('error: ' + textStatus + ': ' + errorThrown); } }); }); }); </code></pre> <p><strong>PHP:</strong></p> <pre><code>try { $dsn = 'mysql:host=localhost;dbname=practice_db'; //your host and database name here. $username = 'root'; $password = ''; //Connect to database $conn = new PDO($dsn, $username, $password); $query = "SELECT * FROM client WHERE client_type = :client_type"; //Prepare and Execute Query $stmt = $conn-&gt;prepare($query); $stmt-&gt;bindParam(':client_type', $type); $stmt-&gt;execute(); //echo 'Here: ' .$stmt; //$rows = $stmt-&gt;fetch(); $rows = $stmt-&gt;fetchAll(); foreach ($rows as $row) { echo "ClientID: ".$row['client_id'] . " "; echo "Name: ".$row['client_name'] . " "; echo "Title: ".$row['client_title'] . " "; echo "Client Type: ".$row['client_type'] . "&lt;br&gt;"; } //Display associative array echo '&lt;pre&gt;'; print_r($rows) .'&lt;br&gt;'; header('Content-type: application/json'); json_encode($rows); print_r(json_encode($rows)); } catch (PDOException $ex) { echo "There was a problem executing the Query: " . $ex-&gt;getMessage(); } </code></pre> <p>Further if i try to check what is the response that i am getting using alert(), it shows: <code>[object HTMLDivElement]</code></p> </div>

始终在pushJsonData中收到错误:parsererror:SyntaxError:我脚本中JSON输入[object Object]的意外结束

<div class="post-text" itemprop="text"> <p>I always receive the Parser error in pushJsonData and I don't know why.</p> <p>I tested it first with just the user value and it works fine, but when I try to thrwo back mor than the user I recieve the error below:</p> <p><code>SyntaxError: Unexpected end of JSON input [object Object]</code></p> <p>My JavaScript code:</p> <pre><code>$('#Login').click(function() { var user = $("#user").val(); $.ajax({ url: "src/ajax.php", type: "POST", data: { ACTION : "checkUser", USER: user}, dataType: "json", success: function(data) { var user = data.user; $('#testUser').text("Hallo " + user); }, error: function(jqXHR, textStatus, errorThrown) { alert(textStatus + " in pushJsonData: " + errorThrown + " " + jqXHR); } }); }); </code></pre> <p>My PHP code:</p> <pre><code>if($_POST['ACTION'] == "checkUser") { $checkUser = $_POST['USER']; $sql = $db-&gt;query("SELECT * FROM fm_user WHERE user = '".$checkUser."' LIMIT 1"); $getUser = $sql-&gt;fetch_assoc(); $resultArray = array( "user" =&gt; $getUser['user'], "isadmin" =&gt; $getUser['isadmin'], "user_data" =&gt; $getUser['user_data'] ); $result = json_encode($resultArray); } </code></pre> </div>

Ajax读本地json文件,无法读取问题

求助各位大神,我用ajax读取本地文件读取不出来,不知道是什么原因。 <script type="text/javascript"> var rate1 = []; var rate2 = []; var date = []; $(document).ready(function () { $('#container').load('datablock/data.json'); $.ajax({ type: "get", url: "datablock/data.json", dataType: "json", async: false, success: function(data){ rate1 = data; alert(data); // $.each(data, function(i, n) { // date[i] = n[0]; // rate1[i] = n[1]; // rate2[i] = n[1]; // }); // rate1 = eval("("+data+""); } }) }) 试用了各种方法依旧无法成功,求助。

AJAX JSON + PHP JSON错误

<div class="post-text" itemprop="text"> <p>I've got a jQuery AJAX code, which recieves JSON-type data from php file. Wihout dataType: "json" everything is ok. But I need JSON-type data. Text recieved is a valid JSON code </p> <blockquote> <p><strong>{"ok":"false","answer":"All fields must be filled"}</strong></p> </blockquote> <p>But when I user dataType, I've got an error </p> <blockquote> <p><strong>Object "parsererror" SyntaxError</strong></p> </blockquote> <p>Here's JS code:</p> <pre><code> $.ajax({ url : "testing/regtest.php", type : "POST", dataType: "json", data : { mail : $('#mail_field').val(), username : $('#username_field').val(), password : $('#password_field').val(), password_2 : $('#rep_password_field').val() }, success : function(data) { console.log(data.ok); }, error: function(a,b,c) { console.log(a,b,c); } }); </code></pre> <p>Thanks for any help! <br> Update: Here's php server-side code: <a href="http://jsfiddle.net/VfQbz/1/" rel="nofollow">http://jsfiddle.net/VfQbz/1/</a> <br> Update 2: It works in IE9 but doesn't work in chrome</p> </div>

ajax中eval()\JSON.parse()\parseJSON()和evalJSON()?

求解这几个方法的区别ajax中eval()、JSON.parse()、parseJSON()和evalJSON()的区别? 其中eval()、JSON.parse()不用导入js文件 parseJSON()需要json.js文件 evalJSON()需要prototype.js文件 这几个中是不是evalJSON()最常用啊?

有没有办法从 package.json 在 nodejs 代码中获得版本?

<div class="post-text" itemprop="text"> <p>Is there a way to get the version set in <code>package.json</code> in a nodejs app? I would want something like this</p> <pre><code>var port = process.env.PORT || 3000 app.listen port console.log "Express server listening on port %d in %s mode %s", app.address().port, app.settings.env, app.VERSION </code></pre> </div> <p>转载于:https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code</p>

由于json,Ajax表单无效(抛出parsererror:SyntaxError:JSON.parse:JSON数据第1行第1列的意外数据结尾)

<div class="post-text" itemprop="text"> <p>I know this question has been asked a lot before but i've tried all the solutions and nothing worked for me so my problem is that i can not load <code>json</code> response from the server using ajax i have my <code>script.js</code> in a js folder and my <code>sendMail.php</code> in includes folder and the <code>index.php</code> is in root folder also when i submit some infos the status is 200 means all ok but also i can not check them with my php code because of <code>json</code> response </p> <p>index.php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Booking&lt;/title&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="js/script.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="includes/sendMail.php" method="POST" name="reservation-form" id="reservation-form"&gt; &lt;div&gt; &lt;select class="select-dropbox" name="mail-hour"&gt; &lt;option value="" disabled selected&gt;Hour&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="text" name="mail-phone" placeholder="Phone Number" &gt; &lt;/div&gt; &lt;div&gt; &lt;input type="text" name="mail-email" placeholder="Email Address" &gt; &lt;/div&gt; &lt;div&gt; &lt;textarea name="mail-msg" placeholder="Your Message" &gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div id="check-form"&gt; &lt;/div&gt; &lt;div&gt; &lt;button id="mail-submit" name="mail-submit" type="submit"&gt;BOOK A TABLE&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>script.js</p> <pre><code>$(document).ready(function(){ $('#mail-submit').click(function(event){ event.preventDefault(); $.ajax({ contentType: "application/json; charset=utf-8", dataType: 'JSON', url: 'includes/sendMail.php', type: 'POST', data: $('#reservation-form').serialize(), beforeSend: function(xhr){ $('#mail-submit').html('SENDING...'); }, success: function(response){ if(respo,se){ alert(response); if(response['signal'] == 'ok'){ $('#check-form').html('&lt;div&gt;'+ response['res-msg'] +'&lt;/div&gt;'); } else{ $('#check-form').html('&lt;div&gt;'+ response['res-msg'] +'&lt;/div&gt;'); } } }, error: function(xhr, status, thrown){ alert("xhr: "+xhr+" status: "+status+" thrown: "+thrown); $('#check-form').html('&lt;div&gt;An Error occurs. Please try again.&lt;/div&gt;'); }, complete: function(){ $('#mail-submit').html('BOOK A TABLE'); } }); }); }); </code></pre> <p>sendMail.php</p> <pre><code>&lt;?php if (isset($_POST['mail-submit'])) { $hour = trim($_POST['mail-hour']); $phone = trim($_POST['mail-phone']); $email = trim($_POST['mail-email']); $message = trim($_POST['mail-msg']); if($hour != null &amp;&amp; $phone != null &amp;&amp; $email != null){ if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $signal = 'bad'; $msg = 'Invalid email. Please check'; } else { $signal = 'ok'; $msg = 'Form submitted'; } } else{ $signal = 'bad'; $msg = 'Please fill in all the fields.'; } $data = array( 'signal' =&gt; $signal, 'res-msg' =&gt; $msg ); echo json_encode($data); } ?&gt; </code></pre> <p><a href="https://i.stack.imgur.com/6hyVz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6hyVz.png" alt="JSON ERROR"></a></p> <p><a href="https://i.stack.imgur.com/WTWR6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WTWR6.png" alt="UPLOADING DATA IS FINE"></a></p> </div>

在AJAX调用期间接收JSON解析错误

<div class="post-text" itemprop="text"> <p>I have a PHP script that is creating my JSON needed for my web app. I am using jQuery's Ajax capabilities to fetch the JSON from my PHP page that is creating the JSON. I am finding a weird quirk though. If I simply run my PHP file in the web browser and output the JSON and then I copy that JSON into a file named <code>myJSON.json</code> which is linked to my Ajax URL call, my code works. However, If I link directly to my PHP file in the Ajax URL call, I get the following error: <strong><code>Requested JSON parse failed</code></strong>. So here is my relevant PHP Code:</p> <pre><code>&lt;?php $groupArray = array(); // Setup the beginning of the json file $json = ' { "emails": ['; // Loop through the request results foreach ($contextIORequest-&gt;getData() as $message) { // `date_received` is in Unix time. Begin converting this to a readable date and convert it to the users timezone $newTZ = new DateTimeZone("America/Chicago"); // This will be based on the users location during production $currentTime = new DateTime(); $currentTime = DateTime::createFromFormat('U', $message['date_received']); $currentTime-&gt;setTimezone($newTZ); $formattedDateReceived = $currentTime-&gt;format('F j, Y'); // The JSON structure is organized by date (group). Each unique date will be placed in its own group in the JSON file. So we need to check if a date is already in the $groupArray. If it is, then we simply add the email data to the current date group. If the date is not already in the $groupArray, then we will need to create a new group and add the email data to the new group. if (!in_array($formattedDateReceived, $groupArray)) { // This date is not yet in the $groupArray // Check if this is the first group being added to the $groupArray. If it is, the first group added requires different formatting than all other groups that will be added if (count($groupArray) == 0) { // This is the first group being added $json .= '{ "group": "'.$formattedDateReceived.'", "list": ['; } else { // This is not the first group being added. Close the previous "group" and "list" objects and then create new "group" and "list" objects. // Before closing the previous "group" and "list" objects, we need to remove the trailing comma ',' from the last "list" item in the previous "group" $json = rtrim($json, ','); // ']' is closing the previous "list" object. '},' is closing the previous "group" object $json .= '] },{ "group": "'.$formattedDateReceived.'", "list": ['; } // Now we need to add this date to the $groupArray $groupArray[] = $formattedDateReceived; // The body of the email cannot have unescaped quotes or apostrophies. It also cannot have line breaks or multiple spaces between words. $body = addslashes($message['body'][0]['content']); // Escapes quotes and apostrophies $body = str_replace(array(" "," "),"", $body); // Removes all line breaks causing the body string to be all on one line $newBody = preg_replace('!\s+!', ' ', $body); // Remove any multiple spaces between words // Add the email to the JSON structure $json .= ' { "id": "'.$message['message_id'].'", "subject": "'.addslashes($message['subject']).'", "to": ["David Nester", "Jane Smith"], "body": "'.$newBody.'", "time": "'.$formattedDateReceived.'", "datetime" : "'.$formattedDateReceived.'", "from": "'.$message['addresses']['from']['name'].'", "dp": "assets/img/profiles/avatar.jpg", "dpRetina": "assets/img/profiles/avatar2x.jpg" },'; // echo "&lt;h1&gt;New Group&lt;/h1&gt;"; // echo "Date: ".$message['date_received']." ($formattedString) &lt;br&gt;"; // echo "From: ".$message['addresses']['from']['email']." &lt;br&gt;"; // echo "Subject: ".$message['subject']." &lt;br&gt;"; // echo "Thread Size: ".$message['thread_size']." &lt;br&gt;"; // echo "Message ID: ".$message['message_id']." &lt;br&gt;"; // echo "Flags: ".$message['flags'][0]." &lt;br&gt;"; } else { // This date is already in the $groupArray // The body of the email cannot have unescaped quotes or apostrophies. It also cannot have line breaks or multiple spaces between words. $body = addslashes($message['body'][0]['content']); // Escapes quotes and apostrophies $body = str_replace(array(" "," "),"", $body); // Removes all line breaks causing the body string to be all on one line $newBody = preg_replace('!\s+!', ' ', $body); // Remove any multiple spaces between words // Add the email to the JSON structure $json .= ' { "id": "'.$message['message_id'].'", "subject": "'.addslashes($message['subject']).'", "to": ["David Nester", "Jane Smith"], "body": "'.$newBody.'", "time": "'.$formattedDateReceived.'", "datetime" : "'.$formattedDateReceived.'", "from": "'.$message['addresses']['from']['name'].'", "dp": "assets/img/profiles/avatar.jpg", "dpRetina": "assets/img/profiles/avatar2x.jpg" },'; } } // end foreach loop // Before closing the very last "group" and "list" objects, we need to remove the trailing comma ',' from the last "list" item in the last "group" $json = rtrim($json, ','); // Complete the JSON structure $json .= '] } ] }'; // Output the JSON file_put_contents('emails.json', $json); header('Content-type: application/json; charset=utf-8'); echo $json; ?&gt; </code></pre> <p>So if I run this PHP file in my web browser, it outputs the JSON. I then copied and pasted the JSON into a JSON file. I then link my AJAX call to the JSON file and everything is parsed correctly. <strong>But</strong> I need to link to the PHP file that creates the JSON in my AJAX call. However, when I do this, I get a parse error even though it is the exact same code I copied and pasted in my JSON file that works perfectly. I am really stumped on this one. Here is my relevant AJAX code as well:</p> <pre><code>$.ajax({ dataType: "json", url: "create-json.php", success: function(data) { $.each(data.emails, function(i) { var obj = data.emails[i]; var list = obj.list; $.each(list, function(j) { var $this = list[j]; var id = $this.id; }); }); }, error: function(jqXHR, exception) { if (jqXHR.status === 0) { alert('Not connect. Verify Network.'); } else if (jqXHR.status == 404) { alert('Requested page not found. [404]'); } else if (jqXHR.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); } else if (exception === 'timeout') { alert('Time out error.'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Uncaught Error. ' + jqXHR.responseText); } } } </code></pre> </div>

JSON解析器错误java.lang.String无法转换为JSONObject] Array

<div class="post-text" itemprop="text"> <p>Hi guys so my problem is ive developed an app for android that uses json parser to get data from my php webservice and display it into a listview, but when i run the app it shows this:</p> <p>LogCat:</p> <pre><code>E/JSON Parser(1999): Error parsing data [Value Array of type java.lang.String cannot be converted to JSONObject] Array 04-02 13:46:46.982: E/JSON Parser(1079): ( 04-02 13:46:46.982: E/JSON Parser(1079): [id] =&gt; 1 04-02 13:46:46.982: E/JSON Parser(1079): [dt_ini_camp] =&gt; 2012-12-22 04-02 13:46:46.982: E/JSON Parser(1079): [dt_fim_camp] =&gt; 2012-12-24 04-02 13:46:46.982: E/JSON Parser(1079): [descricao] =&gt; Apoios comunit?rios 04-02 13:46:46.982: E/JSON Parser(1079): [qtd] =&gt; 4762.000 04-02 13:46:46.982: E/JSON Parser(1079): ) 04-02 13:46:46.982: E/JSON Parser(1079): Array 04-02 13:46:46.982: E/JSON Parser(1079): ( 04-02 13:46:46.982: E/JSON Parser(1079): [id] =&gt; 2 04-02 13:46:46.982: E/JSON Parser(1079): [dt_ini_camp] =&gt; 2012-10-08 04-02 13:46:46.982: E/JSON Parser(1079): [dt_fim_camp] =&gt; 2012-10-10 04-02 13:46:46.982: E/JSON Parser(1079): [descricao] =&gt; Outras Campanhas 04-02 13:46:46.982: E/JSON Parser(1079): [qtd] =&gt; 3560.000 04-02 13:46:46.982: E/JSON Parser(1079): ) </code></pre> <p>My code:</p> <p>Activity with list view and invokes json parser:</p> <pre><code>public class AllProductsActivity extends ListActivity { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; productsList; // url to get all products list private static String url_all_products = "http://10.0.2.2/webprojecto4/index_pesagem.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_PRODUCTS = "cab_doc"; private static final String TAG_ID = "id"; private static final String TAG_NAME = "descricao"; private static final String TAG_DATA = "dt_ini_camp"; private static final String TAG_DATA2 = "dt_fim_camp"; private static final String TAG_QTD = "qtd"; // products JSONArray JSONArray products = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_products); // Hashmap for ListView productsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Loading products in Background Thread new LoadAllProducts().execute(); // Get listview ListView lv = getListView(); // on seleting single product // launching Edit Product Screen // on seleting single product // launching Edit Product Screen lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // getting values from selected ListItem String id2 = ((TextView) view.findViewById(R.id.id)).getText() .toString(); // Starting new intent Intent in = new Intent(getApplicationContext(), EditProductActivity.class); // sending pid to next activity in.putExtra(TAG_ID, id); // starting new activity and expecting some response back startActivityForResult(in, 100); } }); } // Response from Edit Product Activity @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // if result code 100 if (resultCode == 100) { // if result code 100 is received // means user edited/deleted product // reload this screen again Intent intent = getIntent(); finish(); startActivity(intent); } } /** * Background Async Task to Load all product by making HTTP Request * */ class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(AllProductsActivity.this); pDialog.setMessage("Loading products. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting All products from url * */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params); // Check your log cat for JSON reponse Log.d("All Products: ", json.toString()); try { // Checking for SUCCESS TAG int success = json.getInt(TAG_SUCCESS); if (success == 1) { // products found // Getting Array of Products products = json.getJSONArray(TAG_PRODUCTS); // looping through All Products for (int i = 0; i &lt; products.length(); i++) { JSONObject c = products.getJSONObject(i); // Storing each json item in variable String id = c.getString(TAG_ID); String name = c.getString(TAG_NAME); String data = c.getString(TAG_DATA); String data2 = c.getString(TAG_DATA2); String qtd = c.getString(TAG_QTD); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_ID, id); map.put(TAG_NAME, name); map.put(TAG_DATA, data); map.put(TAG_DATA2, data2); map.put(TAG_QTD, qtd); // adding HashList to ArrayList productsList.add(map); } } else { // no products found // Launch Add New product Activity Intent i = new Intent(getApplicationContext(), NewProductActivity.class); // Closing all previous activities i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( AllProductsActivity.this, productsList, R.layout.list_item, new String[] { TAG_ID, TAG_NAME, TAG_DATA, TAG_DATA2, TAG_QTD}, new int[] { R.id.id, R.id.descricao, R.id.data, R.id.data2, R.id.qtd }); // updating listview setListAdapter(adapter); } }); } } } </code></pre> <p>Json Parser in this i only changed this line BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"), 8); instead of utf-8 it was iso-8859-1 ive searched for this error and based on answers i found it said it would be better utf-8 but it didnt fixed the problem</p> <pre><code>public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public JSONParser() { } // function get json from url // by making HTTP POST or GET mehtod public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params) { // Making HTTP request try { // check for request method if(method == "POST"){ // request method is POST // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); }else if(method == "GET"){ // request method is GET DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "utf-8"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + " "); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data [" + e.getMessage()+"] "+json); } // return JSON String return jObj; } } </code></pre> <p>And my php service:</p> <pre><code>&lt;?php /* * Following code will list all the products */ // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/conectaDB.php'; // connecting to db $db = new DB_CONNECT(); // get all products from products table $result = mysql_query("select cd.id, cd.dt_ini_camp, cd.dt_fim_camp, cd.descricao, + (select sum(quantidade) from lin_doc where id_cab_doc = cd.id) as qtd from cab_doc cd where cd.id_tipo_doc = 1") or die(mysql_error()); // check for empty result if (mysql_num_rows($result) &gt; 0) { // looping through all results // products node $response["cab_doc"] = array(); while ($row = mysql_fetch_array($result)) { // temp user array $product = array(); $product["id"] = $row["id"]; $product["dt_ini_camp"] = $row["dt_ini_camp"]; $product["dt_fim_camp"] = $row["dt_fim_camp"]; $product["descricao"] = $row["descricao"]; $product["qtd"] = $row["qtd"]; // push single product into final response array array_push($response["cab_doc"], $product); print_r($product); } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { // no products found $response["success"] = 0; $response["message"] = "No products found"; // echo no users JSON echo json_encode($response); } ?&gt; </code></pre> <p>Please guys i really need help i dont find the problem, the problem i find lol i dont find the answer to my problem xD</p> </div>

获取错误:解析数据时出错org.json.JSONException:org.json.JSONArray类型的值无法转换为JSONObject

<div class="post-text" itemprop="text"> <p>Stuck and need help. JSON parser cannot convert data so I can use the username and password to login.</p> <pre><code>jsonParser = new JSONParser(); public JSONObject loginUser(String username, String password) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("tag", login_tag)); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("password", password)); JSONObject json = jsonParser.getJSONFromUrl(loginURL, params); return json; } </code></pre> <p>PHP part of the code:</p> <pre><code>while($r = mysql_fetch_assoc($result)) { $json[] = $r; } print json_encode($json); </code></pre> </div>

json_encode和JSON.parse错误:SyntaxError:JSON.parse:JSON数据第2行第43行的JSON数据之后的意外非空白字符

<div class="post-text" itemprop="text"> <p>So, I've been trying to send an array from a php file to a script through JSON, using json_encode, but whatever I do, I keep getting the same error: </p> <p>SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 43 of the JSON data</p> <p>Now, I've used jsonlint to validate the JSON received through json_encode, but it shows as not valid.</p> <p>Here's my PHP code/query:</p> <pre><code> &lt;?php require_once '../../DAO/model.php'; $cd = $_POST['cd']; $query = "SELECT ID,name FROM user WHERE cost_center = '$cd' order by name"; $results = mysqli_query($conn, $query); while ($row = mysqli_fetch_assoc($results)){ echo json_encode($row); } ?&gt; </code></pre> <pre><code> $("#centro").change(function(){ var id = $("#centro").val(); $.ajax({ url: 'insertManager.php', method: 'POST', data: {'cd': id} }).done(function(manager){ $('#manager').empty(); console.log(manager); manager = JSON.parse(manager); manager.forEach(function(managers){ $('#manager').append('&lt;option value = "' + managers.id + '"&gt;' + managers.name + '&lt;/option&gt;') }) }) }); </code></pre> <p>And, just to make sure, that is part of the JSON he is generating</p> <pre><code>{ "ID": "RXA47", "name": "Abraao Silva Souza" } { "ID": "F7R53", "name": "Adao David Bueno" } { "ID": "DP800", "name": "Adilson Silva" } { "ID": "C355P", "name": "Adolfo Filho" } </code></pre> <p>I need to be able to iterate through this JSON so I can append the options, but it doesn't even get to that, since it gives me the JSON syntax error, what am I doing wrong?</p> </div>

转换后JSON响应获取空值

转换为NSArray后,JSOn响应得到的是空值 JSON Response : **JSON Log** : [ { "0": "41", "intid": "41", "1": "\u8a00\u3046", "varfirstname": "\u8a00\u3046", "2": "test", "varlastname": "test", "3": "\u5730", "varusername": "\u5730", "4": "abc@gmail.com", "varemailid": "abc@gmail.com", "5": "qwert", "varpassword": "qwert", "6": "12345", "varmobileno": "12345", "7": "Enable", "mobileMessage": "Enable", "8": "", "varphoneno": "", "9": "Enable", "enumstatus": "Enable", "10": "2013-01-30", "date_insert": "2013-01-30", "11": "2013-01-30", "date_edit": "2013-01-30", "12": "210.211.252.1", "varipaddress": "210.211.252.1" } ] 转换NSArray如下: // Create new SBJSON parser object SBJSON *parser = [[SBJSON alloc] init]; NSArray *array = (NSArray *) [parser objectWithString:json_string error:nil]; NSLog(@"Array === %@",array); Array显示数据: Log : Array === ( { 0 = 41; 1 = ""; 10 = "2013-01-30"; 11 = "2013-01-30"; 12 = "210.211.252.1"; 2 = test; 3 = ""; 4 = "abc@gmail.com"; 5 = qwert; 6 = 12345; 7 = Enable; 8 = ""; 9 = Enable; "date_edit" = "2013-01-30"; "date_insert" = "2013-01-30"; enumstatus = Enable; intid = 41; mobileMessage = Enable; varemailid = "abc@gmail.com"; varfirstname = ""; varipaddress = "210.211.252.1"; varlastname = test; varmobileno = 12345; varpassword = qwert; varphoneno = ""; varusername = ""; }) 转换** VarfirstName **如下: NSDictionary *dataObject=[array objectAtIndex:0]; NSString *status = [dataObject objectForKey:@"varfirstname"]; NSLog(@"status -- %@",status); NSString *myDecodedS = status; NSString *myDecoded = [myDecodedS stringByReplacingPercentEscapesUsingEncoding:NSUTF16StringEncoding]; NSLog(@"HIIii %@",myDecoded);

如何在JSON键中使用GO中的switch?

<div class="post-text" itemprop="text"> <p>Here is an example of POST request body:</p> <pre><code>{"action":"do_something","id":"001"} </code></pre> <p>I took an example of simple json parser </p> <pre><code>package main import ( "encoding/json" "fmt" "net/http" ) type some_json struct { Action string `json:"action"` Id string `json:"id"` } func jsonparse(rw http.ResponseWriter, request *http.Request) { decoder := json.NewDecoder(request.Body) var post_data some_json err := decoder.Decode(&amp;post_data) if err != nil { panic(err) } switch ***WHAT_SHOULD_BE_HERE???*** { default : fmt.Fprintf(w,"WRONG PARAM") case "some_thing": fmt.Fprintf(w,post_data.Id + " ") } } func main() { http.HandleFunc("/", jsonparse) http.ListenAndServe(":8080", nil) } </code></pre> <p>I already know how to switch cases from form values, but how to switch cases of json key values?</p> </div>

MySQL 8.0.19安装教程(windows 64位)

话不多说直接开干 目录 1-先去官网下载点击的MySQL的下载​ 2-配置初始化的my.ini文件的文件 3-初始化MySQL 4-安装MySQL服务 + 启动MySQL 服务 5-连接MySQL + 修改密码 先去官网下载点击的MySQL的下载 下载完成后解压 解压完是这个样子 配置初始化的my.ini文件的文件 ...

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉系统全面的介绍。

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

navicat(内含激活码)

navicat支持mysql的可视化操作,内涵激活码,不用再忍受弹框的痛苦。

HTML期末大作业

这是我自己做的HTML期末大作业,花了很多时间,稍加修改就可以作为自己的作业了,而且也可以作为学习参考

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

基于STM32的电子时钟设计

时钟功能 还有闹钟功能,温湿度功能,整点报时功能 你值得拥有

学生成绩管理系统(PHP + MYSQL)

做的是数据库课程设计,使用的php + MySQL,本来是黄金搭配也就没啥说的,推荐使用wamp服务器,里面有详细的使用说明,带有界面的啊!呵呵 不行的话,可以给我留言!

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

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

程序员的兼职技能课

获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:itxy41)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!

实用主义学Python(小白也容易上手的Python实用案例)

原价169,限时立减100元! 系统掌握Python核心语法16点,轻松应对工作中80%以上的Python使用场景! 69元=72讲+源码+社群答疑+讲师社群分享会&nbsp; 【哪些人适合学习这门课程?】 1)大学生,平时只学习了Python理论,并未接触Python实战问题; 2)对Python实用技能掌握薄弱的人,自动化、爬虫、数据分析能让你快速提高工作效率; 3)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; 4)想修炼更好的编程内功,优秀的工程师肯定不能只会一门语言,Python语言功能强大、使用高效、简单易学。 【超实用技能】 从零开始 自动生成工作周报 职场升级 豆瓣电影数据爬取 实用案例 奥运冠军数据分析 自动化办公:通过Python自动化分析Excel数据并自动操作Word文档,最终获得一份基于Excel表格的数据分析报告。 豆瓣电影爬虫:通过Python自动爬取豆瓣电影信息并将电影图片保存到本地。 奥运会数据分析实战 简介:通过Python分析120年间奥运会的数据,从不同角度入手分析,从而得出一些有趣的结论。 【超人气老师】 二两 中国人工智能协会高级会员 生成对抗神经网络研究者 《深入浅出生成对抗网络:原理剖析与TensorFlow实现》一书作者 阿里云大学云学院导师 前大型游戏公司后端工程师 【超丰富实用案例】 0)图片背景去除案例 1)自动生成工作周报案例 2)豆瓣电影数据爬取案例 3)奥运会数据分析案例 4)自动处理邮件案例 5)github信息爬取/更新提醒案例 6)B站百大UP信息爬取与分析案例 7)构建自己的论文网站案例

Java8零基础入门视频教程

这门课程基于主流的java8平台,由浅入深的详细讲解了java SE的开发技术,可以使java方向的入门学员,快速扎实的掌握java开发技术!

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

零基础学C#编程—C#从小白到大咖

本课程从初学者角度出发,提供了C#从入门到成为程序开发高手所需要掌握的各方面知识和技术。 【课程特点】 1 由浅入深,编排合理; 2 视频讲解,精彩详尽; 3 丰富实例,轻松易学; 4 每章总结配有难点解析文档。 15大章节,228课时,1756分钟与你一同进步!

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

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

多功能数字钟.zip

利用数字电子计数知识设计并制作的数字电子钟(含multisim仿真),该数字钟具有显示星期、24小时制时间、闹铃、整点报时、时间校准功能

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

想学好JAVA必须要报两万的培训班吗? Java大神勿入 如果你: 零基础想学JAVA却不知道从何入手 看了一堆书和视频却还是连JAVA的环境都搭建不起来 囊中羞涩面对两万起的JAVA培训班不忍直视 在职没有每天大块的时间专门学习JAVA 那么恭喜你找到组织了,在这里有: 1. 一群志同道合立志学好JAVA的同学一起学习讨论JAVA 2. 灵活机动的学习时间完成特定学习任务+每日编程实战练习 3. 热心助人的助教和讲师及时帮你解决问题,不按时完成作业小心助教老师的家访哦 上一张图看看前辈的感悟: &nbsp; &nbsp; 大家一定迫不及待想知道什么是极简JAVA学习营了吧,下面就来给大家说道说道: 什么是极简JAVA学习营? 1. 针对Java小白或者初级Java学习者; 2. 利用9天时间,每天1个小时时间; 3.通过 每日作业 / 组队PK / 助教答疑 / 实战编程 / 项目答辩 / 社群讨论 / 趣味知识抢答等方式让学员爱上学习编程 , 最终实现能独立开发一个基于控制台的‘库存管理系统’ 的学习模式 极简JAVA学习营是怎么学习的? &nbsp; 如何报名? 只要购买了极简JAVA一:JAVA入门就算报名成功! &nbsp;本期为第四期极简JAVA学习营,我们来看看往期学员的学习状态: 作业看这里~ &nbsp; 助教的作业报告是不是很专业 不交作业打屁屁 助教答疑是不是很用心 &nbsp; 有奖抢答大家玩的很嗨啊 &nbsp; &nbsp; 项目答辩终于开始啦 &nbsp; 优秀者的获奖感言 &nbsp; 这是答辩项目的效果 &nbsp; &nbsp; 这么细致的服务,这么好的氛围,这样的学习效果,需要多少钱呢? 不要1999,不要199,不要99,只要9.9 是的你没听错,只要9.9以上所有就都属于你了 如果你: 1、&nbsp;想学JAVA没有基础 2、&nbsp;想学JAVA没有整块的时间 3、&nbsp;想学JAVA没有足够的预算 还等什么?赶紧报名吧,抓紧抢位,本期只招300人,错过只有等时间待定的下一期了 &nbsp; 报名请加小助手微信:eduxy-1 &nbsp; &nbsp;

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

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

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

机器学习实战系列套餐(必备基础+经典算法+案例实战)

机器学习实战系列套餐以实战为出发点,帮助同学们快速掌握机器学习领域必备经典算法原理并结合Python工具包进行实战应用。建议学习顺序:1.Python必备工具包:掌握实战工具 2.机器学习算法与实战应用:数学原理与应用方法都是必备技能 3.数据挖掘实战:通过真实数据集进行项目实战。按照下列课程顺序学习即可! 课程风格通俗易懂,用最接地气的方式带领大家轻松进军机器学习!提供所有课程代码,PPT与实战数据,有任何问题欢迎随时与我讨论。

Java面试题大全(2020版)

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

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

HoloLens2开发入门教程

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

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

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

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

【数据结构与算法综合实验】欢乐连连看(C++ & MFC)案例

这是武汉理工大学计算机学院数据结构与算法综合实验课程的第三次项目:欢乐连连看(C++ & MFC)迭代开发代码。运行环境:VS2017。已经实现功能:开始游戏、消子、判断胜负、提示、重排、计时、帮助。

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

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

u-boot-2015.07.tar.bz2

uboot-2015-07最新代码,喜欢的朋友请拿去

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问