Under vue, the axios submits the data to the php backend and stores it in mysql. What if I take out the data in json format with double quotation marks?

The offer values of

1 and vue are set as follows:

offer: {
            isshow:false,
            sum_total_price:0,
            sum_discount:0,
            sum_price:0,
            children:[]    
        }
The axios submission code under

2 and vue is as follows:

let postData={
                offer:vm.offer
            }

axios.post("{:url("api/plan/save")}",Qs.stringify(postData))
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });

3, php is stored in mysql after receiving, and printed as follows:

  "offer" => string "{"isshow":"false","sum_total_price":"0","sum_discount":"0","sum_price":"0"}" (length=75)

4, php is read from mysql and input into the template, the code is as follows:

  "offer" => string "{"isshow": "false", "sum_price": "0", "sum_discount": "0", "sum_total_price": "0"}" (length=82)

problem: originally the isshow of offer should be Boolean;
now after being removed from mysql, it is changed into a string by adding double quotes;
isshow used to control the display and hiding of div elements under vue;
can not achieve this effect now;
how to solve this problem of double quotation marks?

Apr.06,2022

A simple idea. Since the data cannot be used directly, it should also be possible to add a judgment

.
ifresponse.offer.isshow=='false' {
    this.offer.isshow==false
}

when the database is pulled out, go straight to json_decode


The problem with

is that Qs.stringify (postData) , passing parameters in the form of application/x-www-form-urlencoded , of course everything is a string.
pass parameters through application/json .

axios.post(url, postData)
  • Query data according to time

    requirement: when the data is saved, the time type used is timestamp, so the current insertion time is automatically saved. Then I need to count the data I inserted, and count it by time period. First, show all the months in which the data exists, click ...

    Sep.01,2021
Menu