How to query mysql in java to get the following results in json format?
大家讲道理
大家讲道理 2017-05-17 09:57:53
0
2
849

Now there are two tables in mysql, one is: table_a, which saves some name, url, page and other field information of the page, and the other table table_b saves the external link information in the page: name, url, table_a, table_b They are related by ID, a one-to-many relationship. Please tell me how to query mysql to obtain the following json result set.

{

"name": "BeJson",
"url": "http://www.bejson.com",
"page": 88,
"isNonProfit": true,   
"links": [
    {
        "name": "Google",
        "url": "http://www.google.com"
    },
    {
        "name": "Baidu",
        "url": "http://www.baidu.com"
    },
    {
        "name": "SoSo",
        "url": "http://www.SoSo.com"
    }
]

}

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
刘奇

What is queried in Java is generally not JSON, but Object. When you want to return the Object to the front end or client, use Jackson or FastJSON to convert the Object into JSON format. I don't know where you want to use JSON, so I can only answer this.

曾经蜡笔没有小新

It has nothing to do with the database, it has to do with the ormap you use, which is the dao layer implementation. Some dao implementations support automatically extracting n data from the database in the case of 1:n.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!