Java解析json-server端的json数据-学生成绩查询小系统

Java解析json-server端的json数据-学生成绩查询小系统-飞一样的编程
飞一样的编程
擅长邻域:Java,MySQL,Linux,nginx,springboot,mongodb,微信小程序,vue

2022-01-01 17:40:59   94浏览 分类: 其他

1.需求:

image.png

2.初始化设计json数据

{
  "student": [
    {
      "id": 1,
      "stuno": "20190115",
      "name": "张三",
      "phone": "15336514240",
      "score": {
        "yuwen": 80,
        "shuxue": 50
      }
    },
    {
      "id": 2,
      "stuno": "20190116",
      "name": "李四",
      "phone": "15336514250",
      "score": {
        "yuwen": 50,
        "shuxue": 90
      }
    },
    {
      "id": 3,
      "stuno": "20190117",
      "name": "王五",
      "phone": "15336515240",
      "score": {
        "yuwen": 50,
        "shuxue": 100
      }
    },
    {
      "stuno": "20190115",
      "name": "王健林",
      "phone": "15336515241",
      "score": {
        "yuwen": 90,
        "shuxue": 50
      },
      "id": 5
    },
    {
      "stuno": "20190118",
      "name": "马云",
      "phone": "15336515241",
      "score": {
        "yuwen": 90,
        "shuxue": 50
      },
      "id": 6
    }
  ]
}

3.json-server操作

3.1准备工作

1.安装json-server

npm install -g json-server

2.查看版本

json-server -v

3.新建一个json文件db.json
4.启动json-server

json-server db.json

image.png

3.2.增:添加一条学生的记录

http://localhost:3000/student/

{
	"stuno": "20190118",
    "name": "马云",
    "phone": "15336515241",
    "score": {
        "yuwen":90,
        "shuxue": 50
    }
 }

image.png

3.3.删除一条记录

http://localhost:3000/student/4
image.png

3.4.修改一条记录

修改id为5的学生信息
发送put请求
http://localhost:3000/student/5
image.png

3.4.查询

3.4.1查id为1的学生信息

发送get请求http://localhost:3000/student/1
image.png

3.4.2查李四的信息

http://localhost:3000/student/?name=李四
image.png

3.4.3查询语文成绩大于等于80的学生

http://localhost:3000/student/?score.yuwen_gte=80
image.png

3.4.4查询所有学生的信息和成绩

get请求http://localhost:3000/student/
image.png

4.Java解析json-server端数据

image.png

5视频讲解


好文章就要一起分享哦!分享海报

此处可发布评论

评论(0

暂无评论,快来写一下吧
客服QQ 1913284695