Supercharge Your Innovation With Domain-Expert AI Agents!

Method for converting Sql result set into Json data based on tree structure

A tree structure and result set technology, applied in the direction of structured data retrieval, electronic digital data processing, database management system, etc., can solve the problem of unable to reflect the hierarchical relationship of row records, and achieve the effect of good promotion and application value.

Pending Publication Date: 2020-03-27
INSPUR SOFTWARE CO LTD
View PDF3 Cites 7 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

In a relational database, each row record in the sql result set is independent in form, and the row records are arranged linearly, which cannot reflect the hierarchical relationship between the row records

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for converting Sql result set into Json data based on tree structure

Examples

Experimental program
Comparison scheme
Effect test

Embodiment

[0021] The method for converting Sql result set based on tree structure to Json data of the present invention obtains sql result set, defines a character string variable root, and introduces an array of key-value pairs at the same time, wherein the primary key is the node number, and the content is the direct subordinate of the node Sub-node collection, continue to loop through subsequent data, if the node number already exists, replace the attributes other than the node number and children, if the node number does not exist, then encapsulate the data and store it in the key-value pair array, insert The parent node number is also cached at the same time. If the parent node number is empty, the parent node number is stored in root. If the parent node number is not empty, find the element whose node number is the parent node number in the key-value pair array. If not found , then add an empty node whose primary key is the parent node number, and then assign the current node numbe...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method for converting an Sql result set into Json data based on a tree structure, and belongs to the technical field of data format conversion. The method for converting theSql result set into Json data based on the tree structure comprises the steps of obtaining an sql result set; defining a character string variable root; introducing a key value pair array, wherein theprimary key is a node number and the content is a direct child node set of the node, and continuously and circularly drilling subsequent data; if the node number exists, replacing attributes except the node number and the children, and if the node number does not exist, packaging the data, storing the packaged data into the key value pair array, and caching the father node number when the data isinserted. The method for converting the Sql result set into the Json data based on the tree structure can effectively solve the problem of transition of format data of the Sql result set, and has good popularization and application value.

Description

technical field [0001] The invention relates to the technical field of data format conversion, and specifically provides a method for converting an Sql result set based on a tree structure to Json data. Background technique [0002] Tree is a very important data structure, and it is widely used in real life, such as personnel management, organization and so on. References to tree structures in web applications generally use the json format, which retains the one-to-many relationship between tree nodes in form. In a relational database, each row record in the SQL result set is independent in form, and the row records are arranged linearly, which cannot reflect the hierarchical relationship between the row records. When developing web applications, the first thing we get is the sql result set selected from the database. To build a tree, we must convert this linear result set into hierarchical json format data. is a complex process. [0003] Due to the inconsistency between ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/25G06F16/248
CPCG06F16/252G06F16/248
Inventor 田大贺
Owner INSPUR SOFTWARE CO LTD
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More