微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将数据从Web检索到JSON之类的格式

如何解决如何将数据从Web检索到JSON之类的格式

我已经尝试使用jsoup抓取数据,并且可以成功从Web查询我需要的所有数据,但是问题是如何使用cssQuery将数据检索到json之类的数据格式示例。

Faculty of Engineering
Computer Science
Washington
Understanding algorithm and data structures Implement to solve real problem Good understanding how computer work

Mechanical Engineering
New York
Understand how machine works Can implement the theory to solve real problem  

Faculty of Science
Mathematics
Toronto
Understand a fundamental concept of Algebra Can Implement the theory to solve real problem Understand number theory

Physics
Chicago
Understand how universe work Understand how to implement the concept to solve real problem Understand fundamental law of physics

我想将其格式化为以下格式

    {
      “<Faculty  name>”: [
        {  “major”: “<major name>”,“location”: “<location>”,“expected output”: [“<expected output>”,“<expected output>”,“<expected output>”],},]
    }

    {
      “Faculty  of Engineering”: [
        {  “major”: “Computer Science”,“location”: “Washington”,“expected output”: [“Understanding algorithm and data structures”,“Implement to solve real problem”,“Good understanding how computer work”],{  “major”: “Mechanical Egineering”,“location”: “New York”,“expected output”: [“Understand how machine works”,“Can implement the theory to solve real problem”]
         },],“Faculty of Science”: [
        {  “major”: “Mathematics”,“location”: “Toronto,“expected output”: [“Understand the fundamental concept of Algebra”,“Can Implement the theory to solve real problem”,“Understand number theory”],{  “major”: “Physics”,“location”: “Chicago”,“expected output”: [“Understand how universe work”,“Understand how to implement the concept to solve real problem”,“Understand fundamental law of physics”]
         },}

我该如何解决这个问题,我先尝试使用gson,同时首先构造了所有元素变量,然后尝试创建一个对象并用值填充它,但是问题在于for循环内的变量,因此我感到困惑我如何放置创建的对象,谢谢。

*请忽略内容,这只是输出数据的示例

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。