Php json error: Cannot use object of type stdClass as array solution, jsonstdclass

Source: Internet
Author: User
Tags php json

Php json error: Cannot use object of type stdClass as array solution, jsonstdclass

When php calls json_decode to generate a json object from a string object, if the [] operator is used to retrieve data, the following error is returned:
Copy codeThe Code is as follows:
Cannot use object of type stdClass as array

Cause:
Copy codeThe Code is as follows:
$ Res = json_decode ($ res );
$ Res ['key']; // use the object after json_decode () as an array.

Solution (2 types ):

1. Use json_decode ($ d, true ). The second variable of json_decode is set to true.
2. json_decode ($ res) returns an object. You cannot use $ res ['key'] for access. You can replace it with $ res-> key.


Php: Uncaught SoapFault exception: [SOAP-ENV: Server] Cannot use object of type stdClass as array

Are you sure your mysql driver is in the project?

1) Start the Tomcat server, open the browser, and enter (localhost is the name server or host ),
Go to the login page of the management interface. At this time, enter the user name and password required during the original installation and log on to the management interface,

2) Select Resources-Data sources to go to the Data source configuration page. Select
Data Source Actions-> select Create New Data Source to go to the configuration details page.
The main content is as follows:
JNDI Name:-> jdbc/mysql
Data Source URL-> jdbc: mysql: // localhost: 3306/test
JDBC Driver Class-> org. gjt. mm. mysql. Driver
3) modify the \ conf \ Catalina \ localhost directory to create an xml file named. xml for your published web application. (For example, testpool. xml) and add the following content:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Context>
<Resource
Name = "jdbc/mysql"
Type = "javax. SQL. DataSource"
Password = "123456"
DriverClassName = "org. gjt. mm. mysql. Driver"
MaxIdle = "2"
MaxWait = "50"
Username = "root"
Url = "jdbc: mysql: // localhost: 3306/test"
MaxActive = "4"/>

</Context>
The content is the same as that in conf/server. xml <GlobalNamingResources>
<Resource
Name = "jdbc/mysql"
Type = "javax. SQL. DataSource"
Password = "123456"
DriverClassName = "org. gjt. mm. mysql. Driver"
MaxIdle = "2"
MaxWait = "50"
Username = "root"
Url = "jdbc: mysql: // localhost: 3306/test"
MaxActive = "4"/>
</GlobalNamingResources>

If this step is missing, the following error occurs: Cannot create JDBC driver of class ''for connect URL... the remaining full text>
 
How to handle Fatal error: Cannot use object of type stdClass as array in

Json data format not parsed
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.