Home > Web Front-end > JS Tutorial > body text

Implementation of json front-end and back-end data interaction methods

不言
Release: 2018-09-18 17:34:21
Original
3173 people have browsed it

The content of this article is about the implementation of json front-end and back-end data interaction methods. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Introduction

Official JSON introduction WIKI Encyclopedia. JavaScript object notation.

JSON: JSON data has two forms, one is an unordered collection of key-value pairs (object), and the other is an ordered collection of values ​​(array).

{string : value, ...} object

    • {
        "birthday": "1996-1-1",
        "name": "王小二",
        "comment": "这是注释",
        "major": [
          "Information",
          "Math"
        ],
        "has_girlFriend": false,
        "age": 22
      }
      Copy after login

      [value, ...] array

    • [{
        "birthday": "1996-1-1",
        "name": "王小二",
        "comment": "这是注释",
        "major": [
          "Information",
          "Math"
        ],
        "has_girlFriend": false,
        "age": 22
      },
      {
        "birthday": "1997-1-1"
      },
        "name",
        "age"
      ]
      Copy after login

There are 7 value forms of value:

  • object, array

  • number, string, (true, false), null

2. Use JSON-java class library

in In java, operations on JSON data.

Mainly the use of the JSONObject class, there are multiple ways to generate JSONObject objects:

Directly generate new JSONObject objects, and put key-value through the put method.

Generate objects by constructing a Map object, putting key-value in through the put method, and then passing in the constructor of the JSONObject object.

Generate objects by constructing a Bean object and then passing in the constructor of the JSONObject object.

Read the text file of JSON data through IO, read the data as a String string, and then pass it into the constructor of the JSONObject object to generate the object.

The above is the detailed content of Implementation of json front-end and back-end data interaction methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template