CN105868167A - Naming resolution method for multiple layers of nested json data - Google Patents
Naming resolution method for multiple layers of nested json data Download PDFInfo
- Publication number
- CN105868167A CN105868167A CN201610140325.9A CN201610140325A CN105868167A CN 105868167 A CN105868167 A CN 105868167A CN 201610140325 A CN201610140325 A CN 201610140325A CN 105868167 A CN105868167 A CN 105868167A
- Authority
- CN
- China
- Prior art keywords
- json format
- data
- format data
- value
- json
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/151—Transformation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/80—Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Computer And Data Communications (AREA)
Abstract
一种n层嵌套的json格式数据的命名解析方法,包括以下步骤:首先,以n层嵌套的json格式数据为基础建立数据源;然后,以键值对为最小单元由外而内依次解析数据;最后,判断是否满足终止条件,满足终止条件则生成的string为解析得到的非嵌套的json格式数据。本发明提供一种在保证数据交换和解析准确性的基础上,提高数据交换和解析效率的n层嵌套的json格式数据的命名解析方法。
A naming analysis method for n-layer nested json-format data, comprising the following steps: firstly, establishing a data source based on n-layer nested json-format data; Parse the data; finally, judge whether the termination condition is satisfied, and if the termination condition is satisfied, the generated string is the non-nested json format data obtained by parsing. The present invention provides a naming analysis method for n-layer nested json format data on the basis of ensuring the accuracy of data exchange and analysis and improving the efficiency of data exchange and analysis.
Description
技术领域technical field
本发明涉及一种通信网络信息、网络规划与通信协议等应用领域,尤其涉及的是一种多层嵌套的json格式数据的命名解析方法。The invention relates to application fields such as communication network information, network planning and communication protocols, and in particular to a method for naming and analyzing multi-layer nested data in JSON format.
背景技术Background technique
随着信息化工业化的快熟发展,企业的信息化水平不断提高,信息交换的不畅通也随之成为信息化建设的一个重大瓶颈。数据交换作为各种计算机网络应用的重要组成部分、已经逐渐成为解决“信息孤岛”现象的主要手段、也是当前信息化建设必须面对的难题。随着Web技术的飞速发展,基于B/S架构的应用越来越丰富,客户端和服务器端数据交换、数据解析的方式也越来越多。在传统的工程应用中,客户端和服务器之间数据交换和数据解析的传统方式,交换和解析的效率较低,严重的影响基于B/S架构系统的系统效果和用户体验,人们在力求寻找一种数据传输开销小的数据交换格式,以提高数据传输的效率,以使得应用程序得到高效的执行,用户的使用体验更好。With the rapid development of informatization and industrialization, the level of informatization of enterprises has been continuously improved, and the unsmooth information exchange has also become a major bottleneck in informatization construction. As an important part of various computer network applications, data exchange has gradually become the main means to solve the phenomenon of "information islands", and it is also a difficult problem that must be faced in the current information construction. With the rapid development of Web technology, applications based on B/S architecture are becoming more and more abundant, and there are more and more methods for data exchange and data analysis between client and server. In traditional engineering applications, the traditional way of data exchange and data analysis between client and server has low exchange and analysis efficiency, which seriously affects the system effect and user experience based on the B/S architecture system. People are trying to find A data exchange format with low data transmission overhead to improve the efficiency of data transmission, so that the application program can be executed efficiently and the user experience is better.
json(JavaScript Object Notation)是一种轻量级的数据交换格式是基于ECMAScript的一个子集。json采用完全独立于语言的文本格式,但是也使用包括C、C++、C#、Java、JavaScript、Perl、Python等类似于C语言家族的习惯。这些特性使json成为理想的数据交换语言。易于人阅读和编写,同时也易于机器解析和生成,大大提升网络传输速率。json格式数据的数据格式比较简单,易于读写,格式经过压缩,占用带宽比较小,同时支持多种语言,便于服务器端解析。对于大多数Web应用来说,根本不需要复杂的XML来传输数据,json数据交换格式提供了更好的简单性和灵活性。JSON (JavaScript Object Notation) is a lightweight data exchange format based on a subset of ECMAScript. json adopts a text format that is completely independent of language, but also uses habits similar to the C language family including C, C++, C#, Java, JavaScript, Perl, Python, etc. These features make JSON an ideal data exchange language. It is easy for people to read and write, and it is also easy for machines to parse and generate, which greatly improves the network transmission rate. The data format of json format data is relatively simple, easy to read and write, the format is compressed, occupies relatively small bandwidth, and supports multiple languages at the same time, which is convenient for server-side analysis. For most web applications, there is no need for complex XML to transfer data at all, and the json data exchange format provides better simplicity and flexibility.
XML扩展标记语言用于标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。XML最大的优势在于对各种数据的管理,任何系统都可以通过XML解析器来读取XML数据,因此它的数据可以通行各处,而不用担心系统不支持的问题。由于XML具有很好跨平台性和通用性,逐渐作为中间媒质来完成数据交换和共享,将用于异构数据库数据交换,较好地克服传统数据交换方式的缺点。然而,XML文件比较庞大,文件格式比较复杂,传输时占用带宽比 较大,服务器端和客户端都需要花费大量代码来解析XML,导致服务器端和客户端代码变得异常复杂且不易维护,客户端和服务器解析XML要花费较多的资源和时间。特别是,在不同浏览器之间解析XML的方式不一致,需要重复编写很多代码,开发效率低下。XML Extended Markup Language is used to mark data and define data types. It is a source language that allows users to define their own markup language. The biggest advantage of XML lies in the management of various data. Any system can read XML data through an XML parser, so its data can pass everywhere without worrying about the problem that the system does not support. Because of its good cross-platform and versatility, XML is gradually used as an intermediate medium to complete data exchange and sharing, and will be used for data exchange of heterogeneous databases, which can better overcome the shortcomings of traditional data exchange methods. However, the XML file is relatively large, the file format is relatively complicated, and the transmission bandwidth is relatively large. Both the server and the client need to spend a lot of code to parse the XML, which makes the server and client code become extremely complicated and difficult to maintain. Parsing XML with the server takes more resources and time. In particular, the ways of parsing XML between different browsers are inconsistent, requiring repeated writing of a lot of codes, and the development efficiency is low.
因此,目前的数据解析技术存在着很多缺陷,需要我们改进。Therefore, there are many defects in the current data parsing technology, which need us to improve.
发明内容Contents of the invention
为了克服已有命名解析方法的数据交换和解析效率较低的不足,本发明提供一种在保证数据交换和解析准确性的基础上提高数据交换和解析效率的多层嵌套的json格式数据的命名解析方法。In order to overcome the deficiencies of low data exchange and analysis efficiency of existing naming analysis methods, the present invention provides a multi-layer nested JSON format data format that improves data exchange and analysis efficiency on the basis of ensuring data exchange and analysis accuracy. Name resolution method.
本发明解决其技术问题所采用的技术方案是:The technical solution adopted by the present invention to solve its technical problems is:
一种多层嵌套的json格式数据的命名解析方法,所述命名解析方法包括以下步骤:A method for naming and analyzing multi-layer nested data in json format, the method for naming and analyzing includes the following steps:
1)参数初始化:设定一组多层嵌套的json格式数据 其中表示json格式数据的键值,表示json格式数据键值对应的值,n表示json格式数据嵌套的层数,m表示第n层对应的json格式数据的组数,k,p,q,l,λ用于标识区分json格式数据的键和值且{k,p,q,l,λ∈N+|0>k>p>q>l>λ};1) Parameter initialization: set a set of multi-layer nested json format data in Indicates the key value of data in json format, Indicates the data key value in json format The corresponding value, n indicates the number of nested layers of json format data, m indicates the number of groups of json format data corresponding to the nth layer, k, p, q, l, λ are used to identify the key and value for distinguishing json format data and {k,p,q,l,λ∈N+|0>k>p>q>l>λ};
2)解析和命名json格式数据,过程如下:2) Parsing and naming json format data, the process is as follows:
2.1)判断str是否为json格式数据,如果str是json格式数据,则进入步骤2.2),否则转入步骤2.6);2.1) judge whether str is json format data, if str is json format data, then enter step 2.2), otherwise proceed to step 2.6);
2.2)设定n=1,m=1,k=1,取json格式数据一组键值对,键值为值为 2.2) Set n=1, m=1, k=1, take a set of key-value pairs of data in json format, and the key value is value is
2.3)判断k>λ是否成立,如果条件成立,进入步骤2.4),否则转入步骤2.8);2.3) Judging whether k>λ is established, if the condition is established, enter step 2.4), otherwise proceed to step 2.8);
2.4)判断value是否为json格式数据,如果条件成立,进入步骤2.5),否则转入步骤2.6);2.4) Determine whether the value is json format data, if the condition is established, enter step 2.5), otherwise proceed to step 2.6);
2.5)以作为新的json格式数据,键值为值为将和拼接形成转入步骤2.3);2.5) to As new json format data, the key value is value is Will and splice formation Go to step 2.3);
2.6)将该键值和值写入新的json格式数据string中,进入步骤2.7);2.6) write the key and value into the new json format data string, and enter step 2.7);
2.7)m=m+1,k=k+1,取json格式数据,键值为值为转入步骤2.3),其中string为生成的新的无嵌套的json格式数据;2.7) m=m+1, k=k+1, take the data in json format, the key value is value is Go to step 2.3), where string is the generated new non-nested json format data;
2.8)解析结束,生成新的无嵌套的json格式数据string为得到的结果。2.8) After the parsing is completed, a new non-nested json format data string is generated as the obtained result.
本发明的技术构思为:首先,以n层嵌套的json格式数据为基础建立数据源;然后,以键值对为最小单元由外而内依次解析数据;最后,判断是否满足终止条件,满足终止条件则生成的string为解析得到的非嵌套的json格式数据。The technical idea of the present invention is as follows: firstly, establish a data source based on n-layer nested json format data; then, use key-value pairs as the smallest unit to analyze the data sequentially from outside to inside; finally, judge whether the termination condition is satisfied, satisfy The string generated by the termination condition is the parsed non-nested JSON format data.
本发明的有益效果为:在保证数据交换和解析准确性的基础上、提高数据交换和解析效率。The beneficial effects of the invention are: on the basis of ensuring the accuracy of data exchange and analysis, the efficiency of data exchange and analysis is improved.
附图说明Description of drawings
图1是一种n层嵌套的json格式数据的命名解析方法示意图。Fig. 1 is a schematic diagram of a naming analysis method for n-layer nested json format data.
具体实施方式detailed description
下面结合附图对本发明作进一步描述。The present invention will be further described below in conjunction with the accompanying drawings.
参照图1,一种多层嵌套的json格式数据的命名解析方法,包括以下步骤:1)参数初始化:设定一组多层嵌套的json格式数据 其中表示json格式数据的键值,表示json格式数据键值对应的值,n表示json格式数据嵌套的层数,m表示第n层对应的json格式数据的组数,k,p,q,l,λ用于标识区分json格式数据的键和值且{k,p,q,l,λ∈N+|0<k<p<q<l<λ};With reference to Fig. 1, a kind of naming analysis method of multi-layer nested json format data comprises the following steps: 1) parameter initialization: set a group of multi-layer nested json format data in Indicates the key value of data in json format, Indicates the data key value in json format The corresponding value, n indicates the number of nested layers of json format data, m indicates the number of groups of json format data corresponding to the nth layer, k, p, q, l, λ are used to identify the key and value for distinguishing json format data and {k,p,q,l,λ∈N+|0<k<p<q<l<λ};
2)解析和命名json格式数据,过程如下:2) Parsing and naming json format data, the process is as follows:
2.1)判断str是否为json格式数据,如果str是json格式数据,则进入步骤2.2),否则转入步骤2.6),如图1中判断str是否为json格式数据;2.1) judge whether str is json format data, if str is json format data, then enter step 2.2), otherwise proceed to step 2.6), as shown in Figure 1, determine whether str is json format data;
2.2)设定n=1,m=1,k=1,取json格式数据一组键值对,键值为值为 2.2) Set n=1, m=1, k=1, take a set of key-value pairs of data in json format, and the key value is value is
2.3)判断k<λ是否成立,如果条件成立,进入步骤2.4),否则转入步骤2.8)如图1中判断条件A是否成立;2.3) judge whether k<λ is established, if the condition is established, enter step 2.4), otherwise proceed to step 2.8) determine whether condition A is established as shown in Figure 1;
2.4)2.4)判断value是否为json格式数据,如果条件成立,进入步骤2.5),否则转入步骤2.6),如图1中判断条件B是否成立;2.4) 2.4) Determine whether the value is data in json format, if the condition is established, enter step 2.5), otherwise proceed to step 2.6), as shown in Figure 1, determine whether condition B is established;
2.5)以作为新的json格式数据,键值为值为将和拼接形成转入步骤2.3);如图1中n与k分别加1,拼接形成键值;2.5) to As new json format data, the key value is value is Will and splice formation Go to step 2.3); as shown in Figure 1, add 1 to n and k respectively, and splicing to form a key value;
2.6)将该键值和值写入新的json格式数据string中,进入步骤2.7),如图1中写入新的json格式数据string;2.6) Write the key and value into the new json format data string, and enter step 2.7), as shown in Figure 1, write the new json format data string;
2.7)m=m+1,k=k+1,取json格式数据,键值为值为转入步骤2.3),其中string为生成的新的无嵌套的json格式数据,如图1中m与k分别加1,拼接形成新键值;2.7) m=m+1, k=k+1, take the data in json format, the key value is value is Go to step 2.3), where string is the generated new non-nesting json format data, as shown in Figure 1, m and k are respectively added by 1, and spliced to form a new key value;
2.8)解析结束,生成新的无嵌套的json格式数据string为得到的结果。2.8) After the parsing is completed, a new non-nested json format data string is generated as the obtained result.
本实施例以字符串 为实施例,一种多层嵌套的json格式数据的命名解析方法,其中包含以下步骤:In this example, the character string As an embodiment, a method for naming and parsing multi-layer nested json format data, which includes the following steps:
1)参数初始化:设定一组n层嵌套的json格式数据其中表示json格式数据的键值,"hanghzou"、"shanghai"、"beijing"表示json格式数据键值对应的值;1) Parameter initialization: set a set of n-layer nested json format data in Indicates the key value of json format data, "hanghzou", "shanghai", "beijing" represent the key value of json format data the corresponding value;
2)解析和命名json格式数据:2) Parsing and naming json format data:
2.1)判断str是否为json格式数据,如果str是json格式数据,则进入步骤2.2),否则转入步骤2.6);2.1) judge whether str is json format data, if str is json format data, then enter step 2.2), otherwise proceed to step 2.6);
2.2)设定n=1,m=1,k=1,取json格式数据一组键值对,键值为值为 2.2) Set n=1, m=1, k=1, take a set of key-value pairs of data in json format, and the key value is value is
2.3)判断k<λ是否成立,如果条件成立,进入步骤2.4),否则转入步骤2.8);2.3) Judging whether k<λ is established, if the condition is established, enter step 2.4), otherwise proceed to step 2.8);
2.4)判断value是否为json格式数据,如果条件成立,进入步骤2.5),否则转入步骤2.6);2.4) Determine whether the value is json format data, if the condition is established, enter step 2.5), otherwise proceed to step 2.6);
2.5)以作为新的json格式数据,键值为值为将和拼接形成转入步骤2.3);2.5) to As new json format data, the key value is value is Will and splice formation Go to step 2.3);
2.6)将该键值和值写入新的json格式数据string中,进入步骤2.7);2.6) write the key and value into the new json format data string, and enter step 2.7);
2.7)m=m+1,k=k+1,取json格式数据,键值为值为转入步骤2.3),其中string为生成的新的无嵌套的json格式数据;2.7) m=m+1, k=k+1, take the data in json format, the key value is value is Go to step 2.3), where string is the generated new non-nested json format data;
2.8)解析结束,生成新的无嵌套的json格式数据
以上阐述的是本发明给出的一个实施例表现出的优良效果,显然本发明不仅适合上述实施例,在不偏离本发明基本精神及不超出本发明实质内容所涉及内容的前提下可对其做种种变化加以实施。What have been set forth above is the excellent effect shown by an embodiment of the present invention, obviously the present invention is not only suitable for the above-mentioned embodiment, can be used under the premise of not departing from the basic spirit of the present invention and not exceeding the content involved in the essence of the present invention Make changes and implement them.
Claims (1)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610140325.9A CN105868167B (en) | 2016-03-11 | 2016-03-11 | A kind of Naming resolution method of the json formatted datas of multilayer nest |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610140325.9A CN105868167B (en) | 2016-03-11 | 2016-03-11 | A kind of Naming resolution method of the json formatted datas of multilayer nest |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN105868167A true CN105868167A (en) | 2016-08-17 |
| CN105868167B CN105868167B (en) | 2018-09-07 |
Family
ID=56625598
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201610140325.9A Active CN105868167B (en) | 2016-03-11 | 2016-03-11 | A kind of Naming resolution method of the json formatted datas of multilayer nest |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105868167B (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110032500A (en) * | 2019-03-01 | 2019-07-19 | 阿里巴巴集团控股有限公司 | Multilayer nest data analysis method and equipment |
| CN112836475A (en) * | 2020-11-24 | 2021-05-25 | 辽宁振兴银行股份有限公司 | A Method of Converting Mixed JSON and XML Data to Two-Dimensional Array |
| CN115146614A (en) * | 2022-06-28 | 2022-10-04 | 平安银行股份有限公司 | Character string processing method and device, electronic equipment and storage medium |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090030920A1 (en) * | 2003-06-25 | 2009-01-29 | Microsoft Corporation | Xsd inference |
| CN105069116A (en) * | 2015-08-11 | 2015-11-18 | 北京思特奇信息技术股份有限公司 | Method and system for converting json string into array |
-
2016
- 2016-03-11 CN CN201610140325.9A patent/CN105868167B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090030920A1 (en) * | 2003-06-25 | 2009-01-29 | Microsoft Corporation | Xsd inference |
| CN105069116A (en) * | 2015-08-11 | 2015-11-18 | 北京思特奇信息技术股份有限公司 | Method and system for converting json string into array |
Non-Patent Citations (2)
| Title |
|---|
| CHARLES SEVERANCE: "Discovering JavaScript Object Notation", 《COMPUTER》 * |
| 雷映喜 等: "XML与JSON在WEB中对数据封装解析的对比", 《价值工程》 * |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110032500A (en) * | 2019-03-01 | 2019-07-19 | 阿里巴巴集团控股有限公司 | Multilayer nest data analysis method and equipment |
| CN112836475A (en) * | 2020-11-24 | 2021-05-25 | 辽宁振兴银行股份有限公司 | A Method of Converting Mixed JSON and XML Data to Two-Dimensional Array |
| CN115146614A (en) * | 2022-06-28 | 2022-10-04 | 平安银行股份有限公司 | Character string processing method and device, electronic equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105868167B (en) | 2018-09-07 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10983971B2 (en) | Detecting duplicated questions using reverse gradient adversarial domain adaptation | |
| CN111538848A (en) | A knowledge representation learning method integrating multi-source information | |
| CN104462460B (en) | A kind of method that body for constructing REST style marks visualization system | |
| WO2021147786A1 (en) | Knowledge graph construction method and apparatus, storage medium, and electronic device | |
| CN111949800A (en) | A method and system for establishing a knowledge graph of an open source project | |
| CN117893807A (en) | Federated self-supervised contrastive learning image classification system and method based on knowledge distillation | |
| CN107798387A (en) | A kind of Knowledge Service System and method suitable for high-end equipment Life cycle | |
| CN113360683B (en) | Method for training cross-modal retrieval model and cross-modal retrieval method and device | |
| CN104462540A (en) | Webpage information extraction method | |
| CN116245177B (en) | Geographic environment knowledge graph automatic construction method and system and readable storage medium | |
| CN115114419A (en) | Question and answer processing method and device, electronic equipment and computer readable medium | |
| CN105868167B (en) | A kind of Naming resolution method of the json formatted datas of multilayer nest | |
| CN105808262B (en) | A kind of name matching process based on json formatted datas | |
| CN119357768B (en) | An encrypted traffic classification method based on hybrid graph structure and dual-channel sequence features | |
| CN118939681A (en) | SQL statement generation method, device, electronic device and storage medium | |
| CN105740370B (en) | A kind of online Web news contents extraction system | |
| Li et al. | [Retracted] Multimedia Data Processing Technology and Application Based on Deep Learning | |
| CN108959255B (en) | Entity labeled data collection construction method, device and equipment | |
| CN103530419B (en) | A kind of Method for Ontology Learning of web oriented service describing | |
| KR101097660B1 (en) | XML Query Processing Method On Wireless Broadcasting Stream | |
| CN103823855B (en) | Chinese encyclopedic knowledge organization and integration method aiming at semantic network | |
| CN116561095A (en) | Data migration method, device, electronic device and storage medium | |
| CN106933844B (en) | Construction method of reachability query index facing large-scale RDF data | |
| CN117891960B (en) | Multimodal hash retrieval method and system based on adaptive gradient modulation | |
| Xiong et al. | When graph meets retrieval augmented generation for wireless networks: A tutorial and case study |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |