json file format

What exactly is json?

In fact, json is just a logical file format like xml.

1. The format of .json includes:

1.json array: 

      char array[20] = "asdflkadk2"; Everyone knows that the C language array looks like this

      json array format [integer, string, boolean, json array, json object] such as: [123, 21.145, true, false, [12,415, "asdfkh"]]

      The type in the above array is a flexible nested array of arrays, nested arrays of arrays, and nested arrays of objects.

      In fact, to sum up, the file format of json is very simple. Write this file format according to your logic level. Just like the nesting of classes and structures in C/C++, you can also use the structure in C. Think of it abstractly as an array with different types of members. Then you can write this json file with a structure member in the structure, and a member with an object in the structure. You can write this json file with a more logical level of data composition, and play as you like. 

2.json object:

       The json object actually requires different requirements 

       Enclosed with {}, {} contains some key-value pairs key: value

       E.g:

      {"name" : " libero", "age" :23 }

remind:

     1. The form of key: value is a bit like the container map in our STL, according to the key value to retrieve the corresponding value value, similar key values ​​cannot be repeated

      2. The  key must be a string, and the value can be any type

 3. json array + json object demo:

      I will give you a small demo

{
	"roomNumber" : "B06",          // 宿舍编号
	"peopleCount" : 6,				// 宿舍人数
    "roomFreeTabels" : 0,			// 宿舍空闲床位
    "roomElemName" : [				// 宿舍人的姓名
    	"libero", 
    	"rock",
    	"martin",
    	"sky",
    	"bingo",
    	"janny"
    ]
}

Note that a json file is generally a large array or a large object, so here we use a large {} to enclose everything

I will share more about C/C++ technology in the following articles, and you can also follow'Qiniu Academy'

Come to discuss together

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_44065088/article/details/107374526