CN110727417A - Data processing method and device - Google Patents

Data processing method and device Download PDF

Info

Publication number
CN110727417A
CN110727417A CN201810689187.9A CN201810689187A CN110727417A CN 110727417 A CN110727417 A CN 110727417A CN 201810689187 A CN201810689187 A CN 201810689187A CN 110727417 A CN110727417 A CN 110727417A
Authority
CN
China
Prior art keywords
original
target
format
text information
template
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
Application number
CN201810689187.9A
Other languages
Chinese (zh)
Other versions
CN110727417B (en
Inventor
陈晓民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Beijing Co Ltd
Original Assignee
Tencent Technology Beijing Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tencent Technology Beijing Co Ltd filed Critical Tencent Technology Beijing Co Ltd
Priority to CN201810689187.9A priority Critical patent/CN110727417B/en
Publication of CN110727417A publication Critical patent/CN110727417A/en
Application granted granted Critical
Publication of CN110727417B publication Critical patent/CN110727417B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the invention discloses a data processing method, which comprises the following steps: acquiring format conversion demand information corresponding to original text information, acquiring a target data format in the format conversion demand information, and acquiring an original key field contained in the original text information; acquiring a configuration template corresponding to the original text information based on the target data format and the original key field; traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value. By adopting the invention, the conversion efficiency of the data format can be improved.

Description

Data processing method and device
Technical Field
The present invention relates to the field of internet technologies, and in particular, to a data processing method and apparatus.
Background
In the development process of APP (Application), a network communication module is generally used, and the network communication module can be used to transmit json (JavaScript Object Notation) data through HTTP (Hyper Text transfer Protocol).
At present, when a terminal receives json data, developers are often required to analyze the received json data according to a specific data interface. And then, artificially reconstructing the analyzed json data according to a specified data format to obtain target data. Therefore, the conversion efficiency of the data format is reduced by the manual operation mode.
Disclosure of Invention
The embodiment of the invention provides a data processing method and device, which can improve the conversion efficiency of data formats.
One aspect of the present invention provides a data processing method, including:
acquiring format conversion demand information corresponding to original text information, acquiring a target data format in the format conversion demand information, and acquiring an original key field contained in the original text information;
acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
Wherein, the obtaining of the configuration template corresponding to the original text information based on the target data format and the original key field includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to the original key field, determining that the format rendering type is a first rendering type, and traversing and searching a configuration template to be matched, which contains the original key field and has the first rendering type, in a configuration library;
and in the configuration templates to be matched, taking the configuration templates to be matched which are consistent with the data output sequence as the configuration templates corresponding to the original text information.
Wherein, the traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value, includes:
analyzing the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
determining the template key fields as first fields to be rendered, traversing and searching original key fields which are the same as the first fields to be rendered in the original text information, acquiring key values corresponding to the searched original key fields, and taking the key values as rendering output results corresponding to the first fields to be rendered based on the first rendering type;
and integrating the plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
Wherein, the obtaining of the configuration template corresponding to the original text information based on the target data format and the original key field includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to a target key field, determining that the format rendering type is a second rendering type, and extracting the target key field in the target data format;
traversing and searching a configuration template to be matched, which comprises the target key field and the original key field, in a configuration library according to the second rendering type;
and in the configuration templates to be matched, taking the configuration templates to be matched which are consistent with the data output sequence as the configuration templates corresponding to the original text information.
Wherein, the traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value, includes:
analyzing the configuration template; the format rendering type of the configuration template is the second rendering type;
and converting the original key field into a target key field with the target data format according to the second rendering type, and assigning a value to the target key field according to a key value corresponding to the original key field to obtain target text information.
Wherein, the converting the original key field into a target key field with the target data format according to the second rendering type, and assigning a value to the target key field according to a key value corresponding to the original key field to obtain target text information includes:
acquiring a plurality of template key fields corresponding to the configuration template; each template key field consists of the original key field and the target key field;
determining the template key fields as second fields to be rendered, traversing and searching the original key fields contained in the second fields to be rendered in the original text information, acquiring key values corresponding to the searched original key fields, and taking the key values as target values corresponding to target key fields in the second fields to be rendered;
carrying out format configuration on the target key field and the target value based on the second format rendering type, and taking the target key field and the target value after format configuration as rendering output results corresponding to the second field to be rendered;
and integrating a plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
Wherein, the obtaining of the configuration template corresponding to the original text information based on the target data format and the original key field includes:
if the target data format comprises a format rendering type corresponding to the original key field, taking the format rendering type as a first rendering type, and determining that a field configuration mode corresponding to the first rendering type is a first configuration mode;
carrying out format configuration on the original key field in the original text information, and converting the original key field after format configuration into a template key field according to the first configuration mode;
and generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
Wherein, the obtaining of the configuration template corresponding to the original text information based on the target data format and the original key field includes:
if the target data format comprises a format rendering type corresponding to the target key field, taking the format rendering type as a second rendering type, and determining that a field configuration mode corresponding to the second rendering type is a second configuration mode;
extracting target key fields in the target data format, and carrying out format configuration on the original key fields in the original text information;
combining the original key field and the target key field after format configuration according to the second configuration mode to generate a template key field;
and generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
Wherein, the obtaining of the original key field included in the original text information includes:
and screening all original key fields in the original text information according to the format conversion requirement information, and determining the screened original key fields as original key fields for generating target text information.
One aspect of the present invention provides a data processing apparatus, including:
the first acquisition module is used for acquiring format conversion demand information corresponding to original text information and acquiring a target data format in the format conversion demand information;
the second acquisition module is used for acquiring an original key field contained in the original text information;
the template acquisition module is used for acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
and the information conversion module is used for traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
Wherein, the template acquisition module comprises:
a first template searching unit, configured to determine that the format rendering type is a first rendering type if the target data format includes the format rendering type and the data output order corresponding to the original key field, and search, in a configuration library, a configuration template to be matched, which includes the original key field and has the first rendering type, in a traversal manner;
and the first template determining unit is used for taking the configuration template to be matched, which is consistent with the data output sequence, as the configuration template corresponding to the original text information in the configuration templates to be matched.
Wherein, the information conversion module includes:
the first template analysis unit is used for analyzing the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
a first rendering unit, configured to determine the template key fields as a first field to be rendered, search, in the original text information, an original key field that is the same as the first field to be rendered, obtain a key value corresponding to the searched original key field, and use the key value as a rendering output result corresponding to the first field to be rendered based on the first rendering type;
and the target determining unit is used for integrating the rendering output results according to the data output sequence and determining the integrated rendering output results as target text information with the target data format.
Wherein, the template acquisition module comprises:
the target field extraction unit is used for determining that the format rendering type is a second rendering type if the target data format comprises a format rendering type and a data output sequence corresponding to a target key field, and extracting the target key field in the target data format;
a second template searching unit, configured to search, in a configuration library, a configuration template to be matched, which includes the target key field and the original key field, in a traversal manner according to the second rendering type;
and the second template determining unit is used for taking the configuration template to be matched, which is consistent with the data output sequence, as the configuration template corresponding to the original text information in the configuration templates to be matched.
Wherein, the information conversion module includes:
the second template analysis unit is used for analyzing the configuration template; the format rendering type of the configuration template is the second rendering type;
and the second rendering unit is used for converting the original key field into a target key field with the target data format according to the second rendering type, and assigning a value to the target key field according to a key value corresponding to the original key field to obtain target text information.
Wherein the second rendering unit includes:
a field obtaining subunit, configured to obtain a plurality of template key fields corresponding to the configuration template; each template key field consists of the original key field and the target key field;
a rendering subunit, configured to determine the template key fields as second fields to be rendered, search, in the original text information, the original key field included in the second fields to be rendered in a traversal manner, acquire a key value corresponding to the searched original key field, and use the key value as a target value corresponding to a target key field in the second fields to be rendered;
a result output subunit, configured to perform format configuration on the target key field and the target value based on the second format rendering type, and use the target key field and the target value after format configuration as a rendering output result corresponding to the second field to be rendered;
and the result integrating subunit is used for integrating the plurality of rendering output results according to the data output sequence and determining the plurality of integrated rendering output results as the target text information with the target data format.
Wherein, the template acquisition module comprises:
a first mode determining unit, configured to, if the target data format includes a format rendering type corresponding to the original key field, take the format rendering type as a first rendering type, and determine that a field configuration mode corresponding to the first rendering type is a first configuration mode;
the first configuration unit is used for carrying out format configuration on the original key field in the original text information and converting the original key field after format configuration into a template key field according to the first configuration mode;
and the first template generating unit is used for generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
Wherein, the template acquisition module comprises:
a second mode determining unit, configured to, if the target data format includes a format rendering type corresponding to the target key field, use the format rendering type as a second rendering type, and determine that a field configuration mode corresponding to the second rendering type is a second configuration mode;
the second configuration unit is used for extracting a target key field in the target data format and carrying out format configuration on the original key field in the original text information;
the second configuration unit is further configured to combine the original key field and the target key field after format configuration according to the second configuration mode, and generate a template key field;
and the second template generating unit is used for generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
The second obtaining module is specifically configured to screen all original key fields in the original text information according to the format conversion requirement information, and determine the screened original key fields as original key fields used for generating the target text information.
One aspect of the present invention provides a data processing apparatus, including: a processor and a memory;
the processor is connected to the memory, wherein the memory is configured to store program codes, and the processor is configured to call the program codes to perform the method according to the above aspect of the embodiment of the present invention.
An aspect of the present invention provides a computer storage medium storing a computer program comprising program instructions that, when executed by a processor, perform a method in the above-mentioned aspect of an embodiment of the present invention.
When the format conversion demand information corresponding to the original text information is obtained, the embodiment of the invention can further obtain a target data format in the format conversion demand information and obtain an original key field contained in the original text information; then, a configuration template corresponding to the original text information is obtained further based on the target data format and the original key field; finally, the original text information can be further traversed based on the configuration template to obtain a key value corresponding to the original key field, and the original text information is converted into target text information with the target data format according to the configuration template and the key value. Therefore, in the process of converting the data format corresponding to the original text information, the format rendering can be directly performed on the original text information through the configuration template, that is, the key value corresponding to the original key field can be quickly acquired according to the configuration template, so as to output the target text information with the specified data format. In view of this, the key value in the original text information can be quickly transmitted to the target text information through the configuration template, and the conversion mechanism of the data format is improved, that is, data reconstruction is not required to be performed artificially, so that the conversion efficiency of the data format can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a network architecture according to an embodiment of the present invention;
FIG. 2 is a flow chart of a data processing method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a method for screening valid primitive key fields according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a lookup configuration template according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating another lookup configuration template according to an embodiment of the present invention;
FIG. 6 is a flow chart illustrating another data processing method according to an embodiment of the present invention;
fig. 7 is a schematic diagram of generating target text information according to an embodiment of the present invention;
FIG. 8 is a flow chart illustrating a further data processing method according to an embodiment of the present invention;
fig. 9 is a schematic diagram of another example of generating target text information according to the embodiment of the present invention;
FIG. 10 is a method for recursively invoking rendering functions according to an embodiment of the present invention;
FIG. 11 is a block diagram of a data processing apparatus according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of another data processing apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a schematic structural diagram of a network architecture according to an embodiment of the present invention. As shown in fig. 1, the network architecture may include a server 2000, a rendering terminal 3000, and a client terminal cluster; the client terminal cluster may include a plurality of client terminals, as shown in fig. 1, specifically including a client terminal 4000a, client terminals 4000b, …, and a client terminal 4000 n;
as shown in fig. 1, the server 2000 is configured to store a plurality of data sources (these data sources may be referred to as raw text information), each data source corresponds to a designated data interface, it should be understood that the data interface may be configured to provide a network communication function between the service terminal 2000 and the rendering terminal 3000, that is, when the rendering terminal 3000 receives a data interface entered by a developer, the rendering terminal 3000 may obtain the raw text information corresponding to the data interface from the service terminal 2000 according to the data interface.
The client terminal 4000a, the client terminals 4000b and …, and the client terminal 4000n may be respectively connected to the rendering terminal 3000 via a network, and may receive target text information having a target data format returned by the rendering terminal 3000. To better understand the present solution, in the embodiment of the present invention, a client terminal may be selected as a target client terminal (taking the target client terminal as the client terminal 4000a as an example) in the client terminal cluster shown in fig. 1, so as to describe a data interaction relationship between the client terminal 4000a and the rendering terminal 3000.
It should be understood that the target text information is obtained by rendering the original text information by the rendering terminal 3000 according to a configuration template, that is, by using the configuration template, the rendering terminal 3000 may convert an original data format corresponding to the original text information into a target data format corresponding to the target text information. For convenience of understanding the present solution, in the embodiments of the present invention, the original text information having a json format may be referred to as original json data, and the target text information having a json format may be referred to as target json data. It should be understood that the data in the two json formats carry different names, respectively, to play different roles in different terminals.
It should be understood that data that satisfies the json rule (i.e., data having a json format) may be referred to as json data. In javascript, the infrastructure of json data can be understood as an object and an array, and thus, various complex structures can be represented by the two structures (i.e., the object and the array).
Wherein the object can be understood as a set of "name/value" pairs (a collection of name/value pairs). It is to be understood that in different languages it may also be understood as a record (record), structure (struct), dictionary (directive), hash table (hash table), keyed list (keyed list), or associative array (associative array). For example, a "name/value pair" may be represented in json format, i.e., { "firstName": Brett "};
the array (array) can be understood as An ordered list of values (ordered list of values). For example, a typical "name/value pair" may be used to represent a set of values, i.e., an array of the json format may be embedded in an object to form an ordered list of values. Thus, multiple bracketed records may be grouped together to represent information for three people with the same attribute (i.e., attribute "peoples"):
Figure BDA0001712471810000091
it should be understood that in this example, there is only one variable named peoples whose value is an array containing three entries, each entry being a record of a person containing a first name, a last name, and an email address. The above example demonstrates how records are grouped into a value with parentheses. Of course, multiple values (each containing multiple records) can be represented using the same syntax, and the description will not be repeated here.
It should be appreciated that json is a native format of JavaScript, which means that no special API (Application Programming Interface) or toolkit is required to process json-formatted data in JavaScript. In JavaScript, a new JavaScript variable can be created, and then json-formatted data is directly assigned to the new JavaScript variable, so as to access a value in the JavaScript variable in JavaScript (for example, a variable named people with a first attribute can be found in JavaScript in a traversal manner, and then a variable named firstName2 with a second attribute is found, so as to access a person with a value of "Jason");
further, the rendering terminal 3000 may convert a set of data represented in the JavaScript object into a character string, and then may easily transfer the character string between functions, or transfer the character string to a target client terminal (e.g., client terminal 4000a) through the rendering terminal 3000 in an asynchronous application.
As shown in fig. 1, the rendering terminal 3000 may be understood as a background service terminal, and the client terminal 4000a may be understood as a foreground terminal, so that the present invention may transmit the key value in the original text information to the target text information having the target data format by means of the configuration template, that is, may implement separation of data and representation.
It should be understood that the data format of the raw data (i.e., the raw data format corresponding to the raw text information) acquired by the rendering terminal 3000 from the service terminal 4000 is different from the data format of the target data (i.e., the target data format corresponding to the target text information) received by the client terminal 4000 a. For example, the raw data may be data in json format (i.e., raw json data), and the raw json data may be: { "data": { "name": charles "} }, the target data is data in json format (i.e. target json data), and the target json data may be: { "value": charles "}. As can be seen, the values of the two json objects are both "charles", but the written json formats are obviously different, so that the rendering terminal 3000 may determine the mapping relationship between different names in the two json objects through a configuration template (for example, { "value": data: name "}), and further may implement separation of data and representation, so as to quickly transmit the key value of the json object in the original text information to the target text information, thereby improving the conversion efficiency of the data format.
It should be understood that the target text information is used for data transmission between a background service terminal and a foreground terminal, that is, when the target text information is obtained by the rendering terminal 3000, the target text information can be returned to the target client terminal. At this time, both the target client terminal and the rendering terminal can identify the target text information, so as to realize the separation of data and expression (namely, complete the transmission of data from the background logical page to the foreground display page). Therefore, the rendering terminal 3000 may interpret the original data format corresponding to the original text information and the original data format corresponding to the target text information as two different data formats.
For ease of understanding, in JavaScript, the rendering terminal 3000 may name the json object in json format as obj1 { "data": name, charles, and the data in the json object: the name is called original text information carrying original data format (namely original json format data). The attributes of the character strings "data" and "name" are collectively referred to as original key fields of obj1(json object), and the attribute of the character string "charles" is a key value of obj1(json object), that is, the key value corresponding to the original key field is "charles". In addition, the invention names the json object in the json format obtained after the conversion of the configuration template as obj2 { "value": charles "}, and the {" value ": charles" in the json object is called as target text information carrying the target data format (namely target json format data). The attribute of the character string "value" is collectively referred to as a target key field of obj2(json object), and the attribute of the character string "charles" is a target value of obj2(json object), that is, the target value corresponding to the target key field is "charles". Therefore, the original json format data can be directly converted into the target json format data through the configuration template, and further, a format conversion mechanism among different json format data can be improved, namely, the target json data which can be identified by the target client terminal can be quickly obtained without manually reconstructing the data and without converting the data format for many times.
As shown in fig. 1, the rendering terminal 3000 may be integrated with the server 2000 in one terminal, and the configuration library 5000 may also be integrated in the rendering terminal. The specific existence form of the rendering terminal 3000 and the configuration library 5000 and the server 2000 will not be limited herein.
It should be understood that the configuration template may be understood as a configuration template to be matched that already exists in the configuration library 5000, that is, the rendering terminal 3000 may directly find the configuration template in the configuration library 5000 according to the target data format and the original key field; of course, the rendering terminal 3000 may further generate the configuration template in real time according to the target data format and the original key field when the configuration template is not found, and add the configuration template to the configuration library 5000, so that the configuration template is continuously found according to the target data format and the original key field when format conversion requirement information (which carries the target data format) of the client terminal 4000a is received in the following.
The target data format may include a format rendering type and a data output order corresponding to the original key field, and therefore, the format rendering type of the configuration template may be referred to as a first rendering type, where the first rendering type is used to output data of a certain field in a data source. At this time, in the configuration template, each template key field is constituted by the original key field. Thus, the rendering terminal 3000 may output the key value corresponding to the original key field in the data source (i.e., the original text information) according to the configuration template, that is, the rendering terminal 3000 may separate the "name/value pair" that satisfies the json format in the original text information according to the first rendering type to obtain the value corresponding to each name, and combine the values into the target file information.
Optionally, the target data format may include a format rendering type and a data output order corresponding to the target key field, and therefore, the format rendering type of the configuration template may be referred to as a second rendering type, where the second rendering type is used to fetch data of a specified path in a data source. At this time, in the configuration template, each template key field is composed of the original key field and the target key field. Therefore, the rendering terminal 3000 may take out the data in the formulated path (i.e., the key value corresponding to the original key field) according to the configuration template, and assign a value to the target key field by using the searched key value corresponding to the original key field, so as to obtain target text information, thereby implementing separation of data and performance.
It can be seen that the rendering terminal 3000 may convert the original text information into the target text information having the target data format, that is, the rendering terminal 3000 may transmit the key value corresponding to the original key field in the original text information to the target text information through the configuration template, so that the rendering terminal 3000 further returns the target text information having the target data format to the target client terminal (client terminal 4000a), so that the target client terminal can identify the target text information having the target data format.
The specific process of obtaining the configuration template, obtaining the key value corresponding to the original key field, and rendering the original text information by the rendering terminal 3000 may refer to the following embodiments corresponding to fig. 2 to fig. 10.
Further, please refer to fig. 2, which is a flowchart illustrating a data processing method according to an embodiment of the present invention. As shown in fig. 2, the method may include:
s101, acquiring format conversion demand information corresponding to original text information, acquiring a target data format in the format conversion demand information, and acquiring an original key field contained in the original text information;
specifically, the rendering terminal may obtain format conversion requirement information corresponding to the original text information, and extract a target data format in the format conversion requirement information; the format conversion requirement information may be extracted by the rendering terminal when receiving a data conversion request sent by a client terminal, and optionally, the format conversion requirement information may also be data information directly sent by the client terminal; then, the rendering terminal may screen all the original key fields in the original text information according to the format conversion requirement information, and determine the screened original key fields as original key fields for generating the target text information, that is, the rendering terminal may determine the screened original key fields as valid original key fields.
The rendering terminal may be the rendering terminal 3000 in the embodiment corresponding to fig. 1; the client terminal may be a target client terminal in the embodiment corresponding to fig. 1, and the client terminal may include a personal computer, a tablet computer, a notebook computer, an intelligent television, an intelligent mobile phone, and other terminal devices with a Web interface display function.
The format conversion requirement information is used for specifying that the rendering terminal needs to output data in a specified format according to a configuration template. For example, the rendering terminal may be required to output a key value corresponding to the original key field in the original text information, and optionally, the rendering terminal may also be required to extract data in a path formulated in the original text information according to a configuration template. In other words, the format conversion requirement information may be used to help the rendering terminal to explicitly perform data rendering according to the first rendering type or perform data rendering according to the second rendering type.
It should be understood that the target data format obtained by the rendering terminal from the format conversion requirement information may include a format rendering type and a data output order corresponding to the original key field, and at this time, the format rendering type of the configuration template may be referred to as a first rendering type, where the first rendering type is used for outputting data of a certain field in a data source. In the configuration template, each template key field is composed of the original key field. Therefore, the rendering terminal may output a key value corresponding to the original key field in the data source (i.e., the original text information) according to the configuration template, that is, the rendering terminal may separate the "name/value pair" that satisfies the json format in the original text information according to the first rendering type to obtain a value corresponding to the name in each json format.
Optionally, the target data format may also include a format rendering type and a data output order corresponding to the target key field, at this time, the format rendering type of the configuration template may be referred to as a second rendering type, and the second rendering type is used to extract data of the formulated path in the data source. Further, in the configuration template, each template key field is constituted by the original key field and the target key field. Therefore, the rendering terminal can take out the data (namely, the key value corresponding to the original key field) in the formulated path according to the configuration template, and assign a value to the target key field according to the key value corresponding to the original key field to obtain target text information, so that the separation of data and performance can be realized.
For convenience of understanding, in the embodiment of the present invention, an original data format corresponding to the original text information is referred to as a json format, where the original text information may be written as { "ret":0}, where { "ret":0} is a json object and may represent a "name/value pair", an attribute of a character string "ret" in the json object may be understood as an original key field in the original text information, and a value 0 is a key value of the json object.
Wherein a json object may be understood as an unordered set of "'name/value' pairs". The written format of the json object is: starting with "{" (left bracket) and ending with "}" (right bracket). Each "name" is followed by one ": colon; the "(comma) separation is used between the" "'name/value' pair".
It should be understood that, when receiving a specified data interface, i.e. a data source interface entered by a developer, the rendering terminal may pull corresponding original text information from a server or receive original text information pushed by the server according to the data interface. Secondly, the rendering terminal can further screen all original key fields in the original text information according to the format conversion requirement information to obtain effective original key fields, namely the effective original key fields which can be used for generating the original key fields of the target text information.
Further, please refer to fig. 3, which is a schematic diagram illustrating a method for screening valid original key fields according to an embodiment of the present invention. As shown in fig. 3, the original text information having the json format and acquired by the rendering terminal may be registration information of 5 users corresponding to the video application a, that is, the original text information shown in fig. 3 includes registration information of 5 users, and the registration information of each user may be represented by two sets of "name/value pairs", that is:
Figure BDA0001712471810000141
therefore, the name in the registration information can be understood as the original key field shown in fig. 3. At this time, if the user with the user name Brett and Jason is using the video application a for live broadcasting and the client terminal needs to check the current use condition of the video application a, the client terminal may request the rendering terminal to output the user information (for example, the login name and the login password of the online user) currently logged in the video application a in the json format. Then, the client terminal may send a data conversion request to the rendering terminal, so that the rendering terminal may obtain the format conversion requirement information shown in fig. 3 from the data conversion request, and further extract the target data format in the format conversion requirement information; at this time, the target data format may include a format rendering type and an output order corresponding to the target key field. At this time, the target key field may be understood as a login name and a login password of the online user, namely, "loading _ name" and "pass _ word". Therefore, the rendering terminal may further screen the data of the online registered users from the 5 registered users as the queried valid data information, that is, the rendering terminal may extract two original key fields identified as X1 and X2 from the 5 original key fields shown in fig. 3 as valid original key fields, that is, the original key fields used for generating the target text information. It should be understood that the symbols X1 and X2 may represent the identity of the user currently using the video application a, and the symbols Y1, Y2, and Y3 may represent the identity of the offline user to which the video application a corresponds. Therefore, the valid original key fields extracted by the rendering terminal may be: the rendering terminal may filter all the original key fields according to the format conversion requirement information to obtain two original key fields as shown in fig. 3, where the original key fields X1 may be "Name1" and "Value1", and the original key fields X2 may be "Name2" and "Value 2"). For ease of understanding, json data corresponding to the two valid original key fields may be referred to as child data of the original json data, and thus, the child data may be:
Figure BDA0001712471810000151
as can be seen, the specific process of the rendering terminal acquiring the original key fields included in the original text information may be understood as that, in the original text information, the original text information is screened according to the format conversion requirement information to obtain effective original key fields, so as to further execute step S102 and step S103. It should be understood that the sub-data may be understood as a virtually existing data, and in practical applications, the sub-data may be referred to as json data used for generating the target text information.
Step S102, acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
specifically, the rendering terminal may search a configuration template corresponding to the original text information according to the target data format and the original key field; optionally, the rendering terminal may further generate the configuration template corresponding to the original text information according to the target data format and the original key field when the configuration template corresponding to the original text information is not found.
The configuration template may reflect a data mapping relationship between the original text information and the target text information.
If the target data format includes the format rendering type and the data output sequence corresponding to the original key field, the rendering terminal may further determine that the format rendering type is a first rendering type, search through a configuration library for a configuration template to be matched, which includes the original key field and has the first rendering type, and use, in the configuration template to be matched, a configuration template to be matched, which conforms to the data output sequence, as the configuration template corresponding to the original text information.
Further, please refer to fig. 4, which is a schematic diagram of a search configuration template according to an embodiment of the present invention. As shown in fig. 4, it is assumed that the original text information is { "data" in json format: { "stats": "complete", "value1": charles "," value2": marry" }), i.e. the original text information is the original text data 10 as shown in fig. 4, which original text data 10 may be referred to as original json data 10. As shown in fig. 4, the original key field 101 in the original text message is: "data", "stats", "value1" and "value2", where the string "data" is the name of the top-level field in the original json data 10, so the field "data" can be referred to as the original critical field with the first attribute (i.e., the top-level field in the original json data 10 can be referred to as the parent), whose value is a set of "name/value pairs", i.e., the string { "stats": "complete", "value1": charles "," value2":" marry "} is the value of the field" data ". The set of "name/value pairs" is composed of three "name/value pairs", each of the field "stats", the field "value1" and the field "value2" has a parent-child relationship with the field "data", and therefore, the three fields (i.e., the field "stats", the field "value1" and the field "value2") can be referred to as an original key field having a second attribute. I.e. the original key field 101 as shown in fig. 4, may comprise both an original key field, i.e. having a first attribute, and an original key field having a second attribute. In the "name/value pair" set, the value of the field "stats" is "complete", the value of the field "value1" is "charles", and the value of the field "value2" is "marry", so the key value 102 in the original json data 10 may include: "complete", "charles" and "marry".
If the client terminal requests the rendering terminal to sequentially output the key value 102 of the original json data 10, that is, the format conversion requirement information received by the rendering terminal is the format conversion requirement information 20 shown in fig. 4, where the format conversion requirement information 20 may be the key value 102 of the original json data 10 that is sequentially output. At this time, the target data format includes a format rendering type and a data output order corresponding to the original key field, and it may be understood that the target data format includes the first rendering type and the data output order as shown in fig. 4. Then, the rendering terminal may determine the format rendering type corresponding to the original key field 101 as a first rendering type, so as to find the configuration template 301 in the configuration library 30 as shown in fig. 4 further according to the first rendering type, the original key field 101, and the data output order.
It should be understood that, in the process of searching the configuration template 301, the rendering terminal may first search through the configuration library 30 to search for the configuration template to be matched, which includes the original key field 101, and has the first rendering type, that is, the rendering terminal may search through the configuration library to search through the configuration template to be matched, which includes the original key field 101, according to the first rendering type. In other words, the rendering terminal may traverse the configuration library 30 to find the configuration template to be matched containing the four original key fields (i.e., "data", "stats", "value1" and "value2"), and the data format of the configuration template to be matched may be:
Format1=data:stats&data:value1&data:value2;
Format2=data:stats&data:value2&data:value1;
Format3=data:value1;
therefore, the rendering terminal needs to use a configuration template to be matched (for example, Format1) that matches the data output sequence among the three configuration templates to be matched as the configuration template corresponding to the original text information (that is, the configuration template may be the configuration template 301 shown in fig. 4).
It should be understood that, when the rendering terminal does not find the configuration template corresponding to the original json data in the configuration library 30 (that is, does not find the configuration template with the data Format of Format1), the rendering terminal may further obtain a field configuration manner corresponding to the first rendering type, and may use the obtained field configuration manner as the first configuration manner, and may perform Format configuration on the original key field 101 in the original text information, that is, convert the original key field 101 into a rendering path for obtaining a key value. Then, the rendering terminal may convert the original key field 101 after the format configuration into a template key field according to the first configuration manner, that is, determine a field in the rendering path as the template key field of the configuration template according to the first configuration manner, and then, the rendering terminal may further generate a configuration template (i.e., the configuration template 301 shown in fig. 4) corresponding to the original text information according to the template key field and the data output sequence in the target data format.
Optionally, if the target data format includes a format rendering type and a data output sequence corresponding to a target key field, determining that the format rendering type is a second rendering type, extracting the target key field in the target data format, traversing and searching a to-be-matched configuration template including the target key field and the original key field in a configuration library according to the second rendering type, and using a to-be-matched configuration template conforming to the data output sequence in the to-be-matched configuration template as a configuration template corresponding to the original text information.
Further, please refer to fig. 5, which is a schematic diagram of another search configuration template according to an embodiment of the present invention. As shown in fig. 5, it is assumed that the original text information is { "message" in json format: { "stats": "complete", "value1": charles "," value2": marry" }, i.e. the original text information may be the original text data 40 as shown in fig. 5, and the original text data 40 may be referred to as the original json data 40. As shown in fig. 5, the original key field 401 in the original text message is: "message", "states", "value1" and "value2", where the field "message" is the name of the top-level field in the original json data 40, so the field "data" can be referred to as the original key field with the first attribute (i.e., the top-level field in the original json data 40 can be referred to as the parent), whose value is a set of "name/value pairs", i.e., the string { "states": "complete", "value1": charles "," value2": marry" } is the value of the field "message". Wherein the set of "name/value pairs" is composed of three "name/value pairs", there is a parent-child relationship between the field "stats", the field "value1" and the field "value2" and the field "message", respectively, so that these three fields (i.e. the field "stats", the field "value1" and the field "value2") can be referred to as the original key field with the second attribute, i.e. the original key field 401 as shown in fig. 5 can include, i.e. have, the first attribute and the original key field with the second attribute. In the "name/value pair" set, the value of the field "stats" is "complete", the value of the field "value1" is "charles", and the value of the field "value2" is "marry", so the key value 402 in the original json data 40 may include: "complete", "charles" and "marry".
If the client terminal requests the rendering terminal to sequentially output a target key field (i.e., the target key field 60 shown in fig. 5) and a target value corresponding to the target key field 60 (the target value is a key value obtained from the original json data 40 according to the original key field 401), the rendering terminal may determine that the target data format includes a format rendering type and a data output sequence corresponding to the target key field 60, and at this time, the rendering terminal may determine the format rendering type corresponding to the target key field 60 as the second rendering type shown in fig. 5, and extract the target key field (i.e., the target key field 60 shown in fig. 5) in the target data format. Next, the rendering terminal may search, in a traversal manner, the configuration library 70 (the configuration library 70 and the configuration library 30 in the embodiment corresponding to fig. 4 may be understood as the same configuration library) according to the second rendering type, for the configuration template to be matched, which includes the target key field 60 and the original key field 401. The data format of the configuration template to be matched may be:
Format1={"stats":"message:stats","first":"message:value1","second":"message:value2"};
Format2={"stats":"message:stats","second":"message:value2","first":"message:value1"};
Format3={"first":"message:value1","stats":"message:stats","second":"message:value2"};
therefore, the rendering terminal needs to use a configuration template to be matched (for example, Format2) that matches the data output sequence among the three configuration templates to be matched as the configuration template corresponding to the original text information (that is, the configuration template may be the configuration template 302 shown in fig. 5).
Optionally, when the rendering terminal does not find the configuration template corresponding to the original json data 40 in the configuration library 70 (i.e., does not find the configuration template with the data Format of Format 2). The rendering terminal may further generate a configuration template 302 corresponding to the original text information based on the target data format and the original key field 401. That is, the rendering terminal may further obtain a field configuration mode corresponding to the second rendering type, regard the obtained field configuration mode as the second configuration mode, further extract the target key field 60 in the target data format, and perform format configuration on the original key field 401 in the original text information, that is, convert the original key field 401 into a rendering path for obtaining the key value 402. Secondly, the rendering terminal may combine the original key field 401 and the target key field 60 after the format configuration according to the second configuration manner (that is, the target key field 60 and the fields in the rendering path form a "name/value pair" set according to a json rule) to generate a template key field, where the template key field is formed by the original key field 401 and the target key field 60. Then, the rendering terminal may further generate a configuration template (i.e., the configuration template 302 shown in fig. 5) corresponding to the original text information according to the template key field and the data output sequence in the target data format.
For example, the data format of the generated configuration template may be: format2 { "stats": message: stats "," second ": message: value2", "first": message: value1 ".
It should be understood that, before generating the above configuration template, the rendering terminal may format the original key field with the first attribute and the original key field with the second attribute in advance, that is, convert the format-configured original key fields into a rendering path for obtaining the key value, that is, the rendering path is composed of original key fields with parent-child relationships, and therefore, the rendering path may be the character strings "message: stands", "message: value1", "message: value 2". The field data is the name of the top-level field in the original json data, so that the rendering path message: states may represent the states field under the field message, the rendering path message: value1 may represent the value1 field under the field message, and the rendering path message: value2 may represent the value2 field under the field message. Then, the rendering terminal may further establish a data mapping relationship between the target key field and the original key field according to format conversion requirement information, that is, the rendering terminal may combine the original key field (i.e., a field in a rendering path) and the target key field after format configuration according to the second configuration mode to further generate a template key field.
The configuration library may be the configuration library 5000 in the embodiment corresponding to fig. 1, where the configuration library includes a plurality of configuration templates, and each configuration template corresponds to one format conversion requirement information. In addition, it should be further understood that the format rendering type of the found configuration template has uniqueness, that is, the format rendering type may be the first rendering type or the second rendering type, and of course, the format rendering type may also be a rendering type of another format besides the first rendering type and the second rendering type, and the format rendering type will not be specifically limited herein.
Therefore, for each acquired format conversion requirement information, if a target data format of data to be output (i.e., target data) is determined, a format rendering type and a data output order included in the target data format may be further determined. Therefore, when the rendering terminal acquires the original json data, the rendering terminal may further render the original json data through the found configuration template, that is, step S103 may be further performed to convert the original json data into target data having a target data format (for example, the original json data may be converted into the target json data).
Step S103, traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
Specifically, the rendering terminal may analyze a configuration template to obtain a plurality of template key fields corresponding to the configuration template; if the format rendering type of the configuration template is the first rendering type, determining the plurality of template key fields as first fields to be rendered, traversing and searching original key fields identical to the first fields to be rendered in the original text information, acquiring key values corresponding to the searched original key fields, taking the key values as rendering output results corresponding to the first fields to be rendered based on the first rendering type, then, the rendering terminal can further integrate a plurality of rendering output results according to the data output sequence, and determining the integrated rendering output results as target text information with the target data format. Optionally, after the rendering terminal parses the configuration template, if the format rendering type of the configuration template is the second rendering type, the rendering terminal may convert the original key field into a target key field having the target data format according to the second rendering type, and assign a value to the target key field according to a key value corresponding to the original key field to obtain target text information.
Wherein, in the process of acquiring the key value in the original json data, when the format rendering type is the first rendering type, taking the template key field as the first field to be rendered (for example, the template key field in the configuration template 301 shown in fig. 4 may be taken as the first field to be rendered), and according to the fields in the rendering path in the first field to be rendered (i.e., the field data and the field stats in the configuration template shown in fig. 4), traversing each original key field 101 in the original text information to find the original key field 101 which is the same as the first field to be rendered in the original text information, so that the key value 102 corresponding to the searched original key field 101 can be obtained (i.e. the key value is: complete), then, the rendering terminal may further use the obtained key value 102 as a rendering output result corresponding to the first field to be rendered. When a plurality of template key fields exist in the configuration template, a plurality of rendering output results can be obtained according to the method for obtaining the key value 102. It should be understood that, at this time, the rendering terminal only obtains the key value 102 in the original json data through the configuration template 301, and therefore, the rendering terminal may further integrate a plurality of rendering output results according to the data output order, and determine the plurality of integrated rendering output results as the target text information in the target data format.
Optionally, in the process of obtaining the key value 102 in the original json data 10, the rendering terminal may also directly traverse the original key field 101 in the original json data 10 according to the rendering path in the configuration template, that is, in the original json data 10, first find the field data with the first attribute, and then further find the field stats with the second attribute under the field data, so as to obtain the key value of the field stats in the original data.
Optionally, if the format rendering type of the configuration template is the second rendering type in the embodiment corresponding to fig. 5, the rendering terminal may further convert the original key field 401 into the target key field 60 having the target data format according to the second rendering type, and assign a value to the target key field 60 according to the key value 402 corresponding to the original key field 401, so as to obtain the target text information.
When the format conversion demand information corresponding to the original text information is obtained, the embodiment of the invention can further obtain a target data format in the format conversion demand information and obtain an original key field contained in the original text information; then, a configuration template corresponding to the original text information is obtained further based on the target data format and the original key field; finally, the original text information can be further traversed based on the configuration template to obtain a key value corresponding to the original key field, and the original text information is converted into target text information with the target data format according to the configuration template and the key value. Therefore, in the process of converting the data format corresponding to the original text information, the format rendering can be directly performed on the original text information through the configuration template, that is, the key value corresponding to the original key field can be quickly acquired according to the configuration template, so as to output the target text information with the specified data format. In view of this, the key value in the original text information can be quickly transmitted to the target text information through the configuration template, and the conversion mechanism of the data format is improved, that is, data reconstruction is not required to be performed artificially, so that the conversion efficiency of the data format can be improved.
Further, please refer to fig. 6, which is a flowchart illustrating another data processing method according to an embodiment of the present invention. As shown in fig. 6, the method may include:
step S201, acquiring format conversion requirement information corresponding to original text information, acquiring a target data format in the format conversion requirement information, and acquiring an original key field contained in the original text information;
it should be understood that the original text information may be understood as original data having an original data format, and the original data format may be a json format, so that, if the format conversion requirement information acquired by the rendering terminal is a key value in original json data output according to a target data format (that is, a specified data format), the rendering terminal may definitely include: and the format rendering type and the data output sequence corresponding to the original key field.
Optionally, the format conversion requirement information may also be a value in the formulated path taken out to the target key field according to a target data format (that is, a specified data format), that is, the rendering terminal needs to output the target key field and a target value corresponding to the target key field together according to the target data format (the target value is the acquired value in the formulated path), and then the rendering terminal may definitely include: and the format rendering type and the data output sequence corresponding to the target key field. And the value in the formulated path is a key value obtained from the original json data.
For better understanding of the present solution, please refer to fig. 7, which is a schematic diagram of generating target text information according to an embodiment of the present invention. As shown in fig. 7, the format conversion requirement information 1a is a key value in the original json data output according to the target data format (i.e. the specified data format), and then the target data format obtained by the rendering terminal from the format conversion requirement information 1a may include: and the format rendering type and the data output sequence corresponding to the original key field. The format rendering type corresponding to the original key field is the first rendering type as shown in fig. 7, and the first rendering type may be understood as a rendering algorithm corresponding to the configuration template 201a, and the original text information (i.e., the original text data 3a shown in fig. 7, and the original text data 3a may be the original json data 3a) having the json format may be converted into the target text information (i.e., the target text information 4a shown in fig. 7) having the target data format by the rendering algorithm.
As shown in fig. 7, the original json data 3a acquired by the rendering terminal (the rendering terminal may refer to the original json data 3a as original text information) is { "data": { "name": value "}, and then the rendering terminal may obtain two original key fields from the original json data (the two original key fields may be referred to as the original key fields 301a shown in fig. 7). Where the original key field 301a is the field "data" and the field "name", it should be understood that the field "data" is the name of the top-level field in the original json data 3a, i.e. the top-level field "data" can be referred to as the parent node in the original json data 3a, and therefore the field "data" can be referred to as the original key field having the first attribute, whose value is a "name/value pair", i.e. the string { "name": value "} is the value of the field" data ". Since the field "name" is a field under the field "data", that is, the field "name" has a parent-child relationship with the field "data", the field "name" can be referred to as an original key field having a second attribute, wherein the string "value" is a value of the field "name". Then, the rendering terminal may use the value (i.e., "value") of the field "name" in the field "data" as the value of the original json data 3a, i.e., the key value 302a in the original json data 3a is "value".
Step S202, if the target data format comprises a format rendering type and a data output sequence corresponding to the original key field, determining that the format rendering type is a first rendering type, and traversing and searching a configuration template to be matched, which contains the original key field and has the first rendering type, in a configuration library;
specifically, after the rendering terminal has executed step S201, the rendering terminal may further extract parameter content carried in the obtained target data format to obtain a format rendering type and a data output order corresponding to the original key field, and at this time, the rendering terminal may make sure that the target data format does not include the target key field, that is, it is not necessary to output "name/value pair" according to a json format. Then, the rendering terminal may further determine that the format rendering type corresponding to the original key field is the first rendering type. Secondly, the rendering terminal may further search, in a configuration library, a configuration template to be matched, which includes the original key field, according to the first rendering type in a traversal manner.
The configuration library may be the configuration library 2a shown in fig. 7, and therefore, the rendering terminal may find the configuration template to be matched, which includes the original key field 2a, in the configuration library 2 a. Since the original key fields 301a shown in fig. 7 are the field "data" and the field "name", the data format of the configuration template to be matched may be: format ═ data: a name; wherein, the character string data: the name can be understood as a rendering path, and the fields in the rendering path are data and name, that is, the fields in the rendering path can be referred to as template key fields of the configuration template, and in this case, the template key fields are all composed of original key fields.
It should be understood that a plurality of configuration templates may exist in the configuration library 2a, and each configuration template corresponds to one format conversion requirement information. Therefore, when the rendering terminal receives the format conversion requirement information, the rendering terminal further determines the format rendering type corresponding to the configuration template according to the format conversion requirement information, so that the original text information can be rendered according to the format rendering type, and the original text information with the original json format is converted into the target text information with the target data format. For example, the rendering terminal may convert json format X into format Y according to format conversion requirement information a, or may convert json format X into format Z according to format conversion requirement information B. The format conversion demand information a and the format conversion demand information B are two different demand information, and therefore the rendering terminal can obtain target text information with different target data formats according to the different demand information.
Step S203, in the configuration templates to be matched, using the configuration template to be matched that matches the data output sequence as the configuration template corresponding to the original text information.
As the original json data 3a shown in fig. 7 is { "data": { "name": value "}, that is, the original json data 3a only contains one key value, when finding the configuration template to be matched containing the original key field 301a, the rendering terminal may determine the configuration template to be matched having the unique rendering path as the configuration template 302a corresponding to the original text information, so as to further perform the subsequent steps S204 to S206, so as to quickly obtain the obtained string value from the original json data 3a, where the string value is the key value 302a shown in fig. 7.
It should be understood that if the original json data 3a shown in fig. 7 is { "data": { "name1": charles "," name2": marry" } and the rendering terminal needs to output key values in multiple original json data, a configuration template to be matched meeting the format output order needs to be found in the configuration library as a configuration template corresponding to the original json data, where the data format of the configuration template to be matched may be:
Format1=data:name1&data:name2;
Format2=data:name2&data:name1;
at this time, the rendering terminal selects one template to be matched from the two configuration templates to be matched as the configuration template corresponding to the original json data according to the data output sequence, so as to further execute step S204-step S206, so that the rendering terminal can further quickly acquire the key value 302a corresponding to the original key field 301a according to the found configuration template.
Step S204, analyzing the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
for example, if the rendering terminal determines that the configuration template 201a is Format data: name 1& data: name2 in step S203, the rendering terminal may obtain a plurality of template key fields corresponding to the configuration template 201a after analyzing the configuration template 201 a. It should be understood that the template key fields are fields in the rendering path, i.e., the template key fields are "data" and "name1", "data" and "name 2". The string data: name1 in the configuration template can be understood as the rendering path corresponding to the original key fields ("data" and "name1"), and similarly, the string data: name2 can be understood as the rendering path corresponding to the original key fields ("data" and "name 2").
Step S205, determining the template key fields as a first field to be rendered, traversing and searching for an original key field identical to the first field to be rendered in the original text information, acquiring a key value corresponding to the searched original key field, and taking the key value as a rendering output result corresponding to the first field to be rendered based on the first rendering type;
at this time, the rendering terminal may use the plurality of template key fields obtained in step S204 as the first field to be rendered, that is, the first field to be rendered is:
"data" and "name 1";
"data" and "name 2".
Then, the rendering terminal may further traverse each original key field in the original text information based on the first field to be rendered to search for an original key field that is the same as the first field to be rendered, and obtain a key value corresponding to the searched original key field, where original json data is { "data": { "name1": charles "," name2": marry" } }, the key value corresponding to each original key field acquired by the rendering terminal through the configuration template may be: charles, marry. Then, the rendering terminal may use each key value as a rendering output result corresponding to the first field to be rendered, respectively, according to the first rendering type.
And step S206, integrating the plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
As shown in fig. 7, if the data output order is the reverse order, that is, the two rendering output results obtained in step S205 need to be output in the reverse order, the rendering terminal may integrate the two rendering output results, and determine the integrated data output result as the target text information having the target data format, that is, the target text information 4a shown in fig. 7 may be: marry & Charles.
It should be understood that the configuration template in the embodiment of the present invention may be understood as a rendering function in the rendering terminal (i.e., the rendering function may be a doRender function, and in practical applications, it may be a rendering function that recursively calls itself). When the rendering function is called, all elements (the elements may be rendering paths in the configuration template) in the configuration template may be traversed, that is, the rendering terminal may use a plurality of template key fields (i.e., fields in the rendering paths) in the configuration template as first fields to be rendered, and search for original key fields that are the same as the first fields to be rendered in the original text information, so as to use key values corresponding to the original key fields as rendering output results, and integrate the rendering output results according to the data output order, so as to obtain target text information having the target data format, that is, to implement outputting values in the original json data.
When the format conversion demand information corresponding to the original text information is obtained, the embodiment of the invention can further obtain a target data format in the format conversion demand information and obtain an original key field contained in the original text information; then, a configuration template corresponding to the original text information is obtained further based on the target data format and the original key field; finally, the original text information can be further traversed based on the configuration template to obtain a key value corresponding to the original key field, and the original text information is converted into target text information with the target data format according to the configuration template and the key value. Therefore, in the process of converting the data format corresponding to the original text information, the format rendering can be directly performed on the original text information through the configuration template, that is, the key value corresponding to the original key field can be quickly acquired according to the configuration template, so as to output the target text information with the specified data format. In view of this, the key value in the original text information can be quickly transmitted to the target text information through the configuration template, and the conversion mechanism of the data format is improved, that is, data reconstruction is not required to be performed artificially, so that the conversion efficiency of the data format can be improved.
Further, please refer to fig. 8, which is a flowchart illustrating another data processing method according to an embodiment of the present invention. As shown in fig. 8, the method may include:
step S301, acquiring format conversion requirement information corresponding to original text information, acquiring a target data format in the format conversion requirement information, and acquiring an original key field contained in the original text information;
further, for better understanding of the present invention, please refer to fig. 9, which is a schematic diagram of another method for generating target text information according to an embodiment of the present invention. As shown in fig. 9, the format conversion requirement information 1b is a target data format, where a target key field and a target value corresponding to the target key field are output together according to the target data format (the target value is a value in an acquired planned path, and the value in the planned path is a key value 302b acquired from original json data 3b), and then the rendering terminal may definitely include: the format rendering type and the data output order corresponding to the target key field 101 b. The format rendering type corresponding to the target key field 101b is the second rendering type as shown in fig. 9, and the second rendering type may be understood as a rendering algorithm corresponding to the configuration template 201b, and the original text information in the json format (i.e. the original text data 3b shown in fig. 9, where the original text data 3b may be referred to as the original json data 3b) may be converted into the target text information in the target data format (i.e. the target text information 4b shown in fig. 9) by the rendering algorithm.
As shown in fig. 9, if the original json data 3b acquired by the rendering terminal (i.e. the rendering terminal may refer to the original json data 3b as original text information) is { "data": name ": charles" }, "ret":0, "msg": success "}, since the original json data 3b includes three sets of" name/value pairs ", the rendering terminal further needs to further screen a plurality of original key fields in the original json data 3b according to the format conversion requirement information 1b to obtain valid original key fields, that is, to determine valid" name/value pairs "in the three sets of" name/value pairs ", that is, the rendering terminal may screen all original key fields in the original text information according to the format conversion requirement information, and determining the screened original key fields as original key fields for generating the target text information. The specific process of the rendering terminal for screening the original key fields in the original json data may join the specific process of screening the valid original key fields in the embodiment corresponding to fig. 3, and details will not be further described here.
For example, the original key fields in the two "name/value pairs" ("data": name ": charles" } and "ret":0) in the original json data 3b may be determined as valid original key fields, which are the original key fields used for obtaining the target text information. At this time, as shown in fig. 9, the original key field 301b may be an original key field for generating target text information.
It should be understood that in this original json data 3b, the original key field 301b may be the original key field in the first "name/value pair" and the original key field in the second "name/value pair". The original key fields in the first "name/value pair" are respectively a field "data" and a field "name", and the field "data" is the name of the top-level field in the original json data, so the field "data" can be referred to as the original key field with the first attribute (i.e. the top-level field in the first "name/value pair" can be referred to as the parent node), and its value is a "name/value pair", i.e. the character string { "name": value "} is the value of the field" data ". The field "name" is a field under the field "data", and therefore, the field "name" can be referred to as an original key field having a second attribute (i.e., there is a parent-child relationship between the field "data" and the field "name"), and in the string { "name": value "}, the string" value "is the value of the field" name ". Then, the rendering terminal may use the value (i.e., "value") of the field "name" in the field "data" as a key value of the original json data 3b, that is, when the original key field is "data" and "name", the rendering terminal may determine that the key value corresponding to the original key field is "value".
Similarly, the original key field in the second "name/value pair" is the field "ret", and the value 0 is the key value corresponding to the original key field. Thus, the original key fields as shown in FIG. 9 may be: the fields "data" and "name" and the field "ret" so that the key value 302b as shown in FIG. 9 may be: the string "value" and the value 0.
Step S302, if the target data format comprises a format rendering type and a data output sequence corresponding to a target key field, determining that the format rendering type is a second rendering type, and extracting the target key field in the target data format;
specifically, after the rendering terminal performs step S301, the rendering terminal may further extract the parameter content carried in the obtained target data format to obtain a format rendering type and a data output order corresponding to the target key field 101b, and at this time, the rendering terminal may determine that the target data format includes the target key field 101 b. Then, the rendering terminal may further determine that the format rendering type corresponding to the original key field is the second rendering type as shown in fig. 9.
Step S303, according to the second rendering type, traversing and searching a configuration template to be matched, which comprises the target key field and the original key field, in a configuration library.
The data format of the configuration template to be matched may be:
Format1={"errcode":"ret","value":"data:name"};
Format2={"value":"data:name","errcode":"ret"}。
when the format rendering type is the second rendering type, the specific search process for the configuration template to be matched may refer to the search process for the configuration template to be matched in the embodiment corresponding to fig. 2, which will not be described again.
Then, the rendering terminal needs to further execute step S304 to determine a configuration template corresponding to the original text information from the multiple configuration templates to be matched according to the data output sequence.
Step S304, in the configuration templates to be matched, taking the configuration templates to be matched which are consistent with the data output sequence as the configuration templates corresponding to the original text information;
at this time, if the format conversion requirement information is that the value of the original key field is output to the target text information in a reverse order, that is, the data output order is a reverse order to output a plurality of rendering output results, the first to-be-matched configuration template in the to-be-matched configuration templates searched in the step S303 may be used as the configuration template corresponding to the original text information, that is, the data format of the configuration template is as follows: format1 { "error": "ret", "value": data: name "}.
Optionally, when the rendering terminal does not find the configuration template corresponding to the original json data in the configuration library (that is, does not find the configuration template having the data Format of Format1), the rendering terminal may further obtain a field configuration manner corresponding to the second rendering type, and use the obtained field configuration manner as the second configuration manner, and further extract that the target key field 101b in the target data Format may be the field "error" and the field "value", and perform Format configuration on the original key field in the original text information, that is, convert the original key field into a rendering path (that is, ret and data: name) for obtaining a key value. Secondly, the rendering terminal may combine the original key field and the target key field after the format configuration according to the second configuration manner (that is, the target key field and the fields in the rendering path form a "name/value pair" set according to a json rule) to generate a template key field, where the template key field is formed by the original key field and the target key field. Then, the rendering terminal may further generate a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format (i.e., may obtain a configuration template 201b as shown in fig. 9).
Thus, the data format of the generated configuration template 201b may be: format1 { "error": "ret", "value": data: name "}.
Step S305, analyzing the configuration template;
wherein, it should be understood that the format rendering type of the configuration template is the second rendering type;
step S306, a plurality of template key fields corresponding to the configuration template are obtained;
wherein each template key field is composed of the original key field and the target key field. The character strings "error code" and "value" are names of output fields, that is, the target key field is the field "error code" and the field "value", the original key field is the field "ret", and the field "data" and the field "name". It should be understood that in the configuration template 201b, each template may contain a plurality of "name/value pair" sets, and therefore, in the configuration template 201b, the value corresponding to the target key field may be a fixed rendering path, or may be a json object containing a certain rendering path.
Step S307, determining the template key fields as second fields to be rendered, traversing and searching the original key fields contained in the second fields to be rendered in the original text information, acquiring the key values corresponding to the searched original key fields, and taking the key values as target values corresponding to target key fields in the second fields to be rendered;
step S308, carrying out format configuration on the target key field and the target value based on the second format rendering type, and taking the target key field and the target value after format configuration as rendering output results corresponding to the second field to be rendered;
it should be understood that, at this time, format configuring the target key field and the target value is to write the target key field 101b and the target value (the target value is the obtained key value 302b shown in fig. 9) into a "name/value pair" having a json format according to a json rule, so as to use the target key field and the target value after format configuration as a rendering output result corresponding to the second field to be rendered, and at this time, the "name/value pair" in the rendering output result may be { "value": charles "and {" error ":0 }).
Step S309, integrating a plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
At this time, the target text information may be { "error": 0, "value": charles "}. Therefore, the rendering terminal can integrate a plurality of rendering output results according to the data output sequence to obtain the target text information with the target data format.
It should be appreciated that when the configuration template rendering fails, a default value named default will be returned to the client terminal. For example, in the process that the rendering terminal renders the original json data by using the configuration template (Format1 { "error": ret "," value ": data: name" } & default { "error": 1}), if the rendering terminal crashes, the target text information required by the client terminal cannot be rendered and output, which may cause rendering failure. Therefore, the rendering terminal returns the character string { "error": 1} as bottom-of-pocket data to the client terminal, so that the client terminal knows that the rendering terminal target cannot perform rendering processing on the current original json data.
It should be understood that, when the configuration template in the embodiment of the present invention is used in the rendering terminal, it may be understood as calling a rendering function in the rendering terminal (that is, the rendering function may be a doRender function, and in practical applications, it may be a rendering function that recursively calls itself, that is, when a value of a target key field in the configuration template is a json object, the rendering function needs to be recursively called multiple times). When the rendering function is called, all elements in the configuration template may be traversed, it should be understood that an element in the configuration template may be understood as a value of a target key field in the configuration template, the value of the target key field may be a fixed rendering path, and in the configuration template, each template key field is composed of a target key field and a field (i.e., an original key field) in the rendering path. Therefore, the rendering terminal may use a plurality of template key fields in the configuration template as second fields to be rendered, traverse and search the original key fields included in the second fields to be rendered in the original text information, use the key values corresponding to the searched original key fields as target values corresponding to target key fields in the configuration template, perform format configuration on the target key fields and the target values based on the second format rendering type, and use the target key fields and the target values after format configuration as rendering output results corresponding to the second fields to be rendered. For convenience of understanding, the rendering terminal collectively refers to the plurality of template key fields in the configuration template as a second field to be rendered, and when the rendering function is called, a rendering output result corresponding to each template key field can be collectively obtained. Then, the rendering terminal may integrate the plurality of rendering output results according to the data output order, and determine the plurality of integrated rendering output results as target text information having the target data format.
For example, in the configuration template 201b shown in fig. 9, the target key field is "error", the value corresponding to the target key field is a fixed rendering path, and the rendering path is the character string "ret". When the rendering terminal determines that the value corresponding to the target key field is a character string, it may further search, in the original text information, the original key field included in the second field to be rendered in a traversal manner (i.e., in the original josn data 3b, the field "ret" in the original key field 301b is searched in a traversal manner), so as to use the key value 302b (i.e., the numerical value 0) corresponding to the original key field 301b as the target value of the target key field; then, the rendering terminal may form the target key field and the target value into a "name/value pair" form according to a json rule, so as to obtain a rendering output result corresponding to the second field to be rendered.
It should be appreciated that for each template key field in a configuration template, a corresponding rendering output result may be obtained by calling the rendering function. Thereby, the target text information having the target data format can be obtained. It should be understood that, subsequently, if the client terminal requests the rendering terminal to output data in other formats, the rendering terminal may use the request as a new format conversion requirement information to find a corresponding configuration template in the configuration library according to the above method, so that the original text information can be rendered without changing the program or restarting the system.
For another example, when the original text data 3b shown in fig. 9 is { "aa": { "bb": value "} and the configuration template 201b located by the rendering terminal is {" a ": {" b ": {" c ": aa: bb" } further referring to fig. 10, it is a method for recursively invoking the rendering function according to an embodiment of the present invention. As shown in FIG. 10, the rendering terminal parses the configuration template 201b for the first time, determining that the value of the target key field "a" in the configuration template 201b is a json object, which may be the object 10a shown in FIG. 10, the object 10a being { "b": { "c": aa: bb }. Since the value of the target key field "a" is a json object, the rendering terminal needs to perform recursive parsing on the json object, i.e. continue to call the rendering function to perform the second parsing on the object 10a, so as to obtain the object 20a shown in fig. 10, where the object 20a is { "c": "aa: bb"). Similarly, the rendering terminal still needs to further call the rendering function to perform a third parsing on the object 20a to determine that the value of the target key field in the object 20a is a fixed rendering path, where the rendering path is aa: bb. Secondly, the rendering terminal may further search the original key field identical to the field in the rendering path (aa: bb) in the original text data 3b to retrieve a key value (value) corresponding to the original key field. Then, the rendering terminal may further assign the value to the field c (i.e. perform the first assignment), resulting in a result 10a as shown in fig. 10, where the result 10a may be understood as the output result to be rendered, i.e., { "c": value "}; the rendering terminal may then further use the output result to be rendered (i.e., { "c": value "}) as the target value of field b (i.e., perform the second assignment) to obtain a result 20a as shown in fig. 10, the result 20a may be understood as a new output result to be rendered, i.e., {" b ": c": value "}), and finally, the rendering terminal may further use the new output result to be rendered as the target value of field a (i.e., perform the third assignment) to obtain a result 30a as shown in fig. 10, the result 30a may be understood as the target text information, i.e., {" a ": {" b ": c": value "}. It can be seen that the rendering function is recursively called many times in the process of generating the target text information.
When the format conversion demand information corresponding to the original text information is obtained, the embodiment of the invention can further obtain a target data format in the format conversion demand information and obtain an original key field contained in the original text information; then, a configuration template corresponding to the original text information is obtained further based on the target data format and the original key field; finally, the original text information can be further traversed based on the configuration template to obtain a key value corresponding to the original key field, and the original text information is converted into target text information with the target data format according to the configuration template and the key value. Therefore, in the process of converting the data format corresponding to the original text information, the format rendering can be directly performed on the original text information through the configuration template, that is, the key value corresponding to the original key field can be obtained according to the configuration template, so as to output the target text information with the specified data format. In view of this, the key value in the original text information can be quickly transmitted to the target text information through the configuration template, and the conversion mechanism of the data format is improved, that is, data reconstruction is not required to be performed artificially, so that the conversion efficiency of the data format can be improved.
Further, please refer to fig. 11, which is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention. As shown in fig. 11, the data processing apparatus 1 may be the rendering terminal 3000 in the embodiment corresponding to fig. 1, and the data processing apparatus 1 may include: a first obtaining module 10, a second obtaining module 20, a template obtaining module 30 and an information conversion module 40;
the first obtaining module 10 is configured to obtain format conversion requirement information corresponding to original text information, and obtain a target data format in the format conversion requirement information;
the second obtaining module 20 is configured to obtain an original key field included in the original text information;
specifically, the second obtaining module 20 is specifically configured to filter all original key fields in the original text information according to the format conversion requirement information, and determine the filtered original key fields as original key fields used for generating the target text information.
The template obtaining module 30 is configured to obtain a configuration template corresponding to the original text information based on the target data format and the original key field;
wherein the template obtaining module 30 includes: a first template search unit 301 and a first template determination unit 302;
the first template searching unit 301 is configured to determine that the format rendering type is a first rendering type if the target data format includes the format rendering type and the data output order corresponding to the original key field, and search, in a configuration library, a configuration template to be matched, which includes the original key field and has the first rendering type, in a traversal manner;
the first template determining unit 302 is configured to use, in the configuration templates to be matched, a configuration template to be matched that matches the data output sequence as a configuration template corresponding to the original text information.
For specific implementation processes of the first template searching unit 301 and the first template determining unit 302, reference may be made to the description of step S202 to step S203 in the embodiment corresponding to fig. 6, and details will not be further described here.
Optionally, the template obtaining module 30 may also include: a target field extracting unit 303, a second template searching unit 304 and a second template determining unit 305;
the target field extracting unit 303 is configured to determine that the format rendering type is a second rendering type if the target data format includes a format rendering type and a data output order corresponding to a target key field, and extract the target key field in the target data format;
the second template searching unit 304 is configured to search, in a traversal manner in a configuration library, a configuration template to be matched, which includes the target key field and the original key field, according to the second rendering type;
the second template determining unit 305 is configured to use, in the configuration templates to be matched, a configuration template to be matched that matches the data output sequence as a configuration template corresponding to the original text information.
For specific implementation processes of the target field extracting unit 303, the second template searching unit 304, and the second template determining unit 305, reference may be made to the description of step S302 to step S305 in the embodiment corresponding to fig. 8, and details will not be further described here.
It should be understood that, when the first template searching unit 301 and the first template determining unit 302 are used to search for the configuration template corresponding to the original text information, the template obtaining module 30 will not search for the configuration template corresponding to the original text information through the target field extracting unit 303, the second template searching unit 304 and the second template determining unit 305. Conversely, when the template obtaining module 30 searches for the configuration template corresponding to the original text information through the target field extracting unit 303, the second template searching unit 304 and the second template determining unit 305, the configuration template corresponding to the original text information will not be searched for through the first template searching unit 301 and the first template determining unit 302.
Optionally, when the template obtaining module 30 in the data processing apparatus 1 is configured to not search the configuration template corresponding to the original text information in the configuration library, if the configuration template corresponding to the original text information is found, the template obtaining module 30 may be further configured to generate the configuration template corresponding to the original text information; at this time, the template obtaining module 30 may include: a first mode determination unit 306, a first configuration unit 307, and a first template generation unit 308;
the first mode determining unit 306 is configured to, if the target data format includes a format rendering type corresponding to the original key field, use the format rendering type as a first rendering type, and determine that a field configuration mode corresponding to the first rendering type is a first configuration mode;
the first configuration unit 307 is configured to perform format configuration on the original key field in the original text information, and convert the original key field after format configuration into a template key field according to the first configuration mode;
the first template generating unit 308 is configured to generate a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
For specific implementation manners of the first method determining unit 306, the first configuring unit 307, and the first template generating unit 308, reference may be made to the description of generating the configured template corresponding to the original text information in the embodiment corresponding to fig. 6, and details will not be further described here.
Optionally, the template obtaining module 30 may further include: a second mode determination unit 309, a second configuration unit 310, and a second template generation unit 311;
the second mode determining unit 309, configured to, if the target data format includes a format rendering type corresponding to the target key field, use the format rendering type as a second rendering type, and determine that a field configuration mode corresponding to the second rendering type is a second configuration mode;
the second configuration unit 310 is configured to extract a target key field in the target data format, and perform format configuration on the original key field in the original text information;
the second configuration unit 310 is further configured to combine the original key field and the target key field after format configuration according to the second configuration manner, so as to generate a template key field;
the second template generating unit 311 is configured to generate a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
For specific implementation manners of the second manner determining unit 309, the second configuring unit 310 and the second template generating unit 311, reference may be made to the description of generating the configuration template corresponding to the original text information in the embodiment corresponding to fig. 8, and details will not be further described here.
It should be understood that, when the template obtaining module 30 generates the configuration template corresponding to the original text information through the first mode determining unit 306, the first configuring unit 307 and the first template generating unit 308, the configuration template corresponding to the original text information will not be generated through the second mode determining unit 309, the second configuring unit 310 and the second template generating unit 311. Of course, when the template obtaining module 30 generates the configuration template corresponding to the original text information through the second mode determining unit 309, the second configuring unit 310 and the second template generating unit 311, the configuration template corresponding to the original text information will not be generated through the first mode determining unit 306, the first configuring unit 307 and the first template generating unit 308.
The information conversion module 40 is configured to traverse the original text information based on the configuration template to obtain a key value corresponding to the original key field, and convert the original text information into target text information having the target data format according to the configuration template and the key value.
Wherein, the information conversion module 40 includes: a first template parsing unit 401, a first rendering unit 402, and a target determination unit 403;
the first template analysis unit 401 is configured to analyze the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
the first rendering unit 402 is configured to determine the template key fields as first fields to be rendered, search, in the original text information, an original key field that is the same as the first fields to be rendered, obtain a key value corresponding to the searched original key field, and use the key value as a rendering output result corresponding to the first fields to be rendered based on the first rendering type;
the target determining unit 403 is configured to integrate the multiple rendering output results according to the data output order, and determine the multiple integrated rendering output results as target text information having the target data format.
For specific implementation processes of the first template analyzing unit 401, the first rendering unit 402, and the target determining unit 403, reference may be made to the description of step S204 to step S206 in the embodiment corresponding to fig. 6, and details will not be further described here.
Optionally, the information conversion module 40 includes: a second template parsing unit 404 and a second rendering unit 405;
the second template parsing unit 404 is configured to parse the configuration template; the format rendering type of the configuration template is the second rendering type;
the second rendering unit 405 is configured to convert the original key field into a target key field with the target data format according to the second rendering type, and assign a value to the target key field according to a key value corresponding to the original key field to obtain target text information.
Wherein the second rendering unit 405 includes: a field acquisition subunit 4051, a rendering subunit 4052, a result output subunit 4053, and a result integration subunit 4054;
the field obtaining subunit 4051 is configured to obtain a plurality of template key fields corresponding to the configuration template; each template key field consists of the original key field and the target key field;
the rendering subunit 4052 is configured to determine the template key fields as second fields to be rendered, search, in the original text information, the original key fields included in the second fields to be rendered in a traversing manner, acquire key values corresponding to the searched original key fields, and use the key values as target values corresponding to target key fields in the second fields to be rendered;
the result output subunit 4053 is configured to perform format configuration on the target key field and the target value based on the second format rendering type, and use the target key field and the target value after format configuration as a rendering output result corresponding to the second field to be rendered;
the result integrating subunit 4054 is configured to integrate the multiple rendering output results according to the data output order, and determine the multiple integrated rendering output results as the target text information in the target data format.
For specific implementation processes of the field obtaining subunit 4051, the rendering subunit 4052, the result outputting subunit 4053, and the result integrating subunit 4054, reference may be made to the description of steps S306 to S309 in the embodiment corresponding to fig. 8, and details will not be further described here.
For specific implementation processes of the second template parsing unit 404 and the second rendering unit 405, reference may be made to the description of step S305 to step S309 in the embodiment corresponding to fig. 8, and details will not be further described here.
It should be understood that, when the information conversion module 40 performs rendering processing on original text information by the first template parsing unit 401, the first rendering unit 402 and the target determination unit 403, the original text information will not be subjected to rendering processing by the second template parsing unit 404 and the second rendering unit 405; of course, when the information conversion module 40 performs rendering processing on the original text information through the second template parsing unit 404 and the second rendering unit 405, the original text information will not be subjected to rendering processing through the first template parsing unit 401, the first rendering unit 402, and the target determination unit 403.
For specific implementation processes of the first obtaining module 10, the second obtaining module 20, the template obtaining module 30 and the information converting module 40, reference may be made to the description of step S101 to step S103 in the embodiment corresponding to fig. 2, and details will not be further described here.
When the format conversion demand information corresponding to the original text information is obtained, the embodiment of the invention can further obtain a target data format in the format conversion demand information and obtain an original key field contained in the original text information; then, a configuration template corresponding to the original text information is obtained further based on the target data format and the original key field; finally, the original text information can be further traversed based on the configuration template to obtain a key value corresponding to the original key field, and the original text information is converted into target text information with the target data format according to the configuration template and the key value. Therefore, in the process of converting the data format corresponding to the original text information, the format rendering can be directly performed on the original text information through the configuration template, that is, the key value corresponding to the original key field can be obtained according to the configuration template, so as to output the target text information with the specified data format. In view of this, the present invention can transmit the key value in the original text message to the target text message by means of the configuration template, and simplify the conversion process of the data format, so as to improve the conversion efficiency of the data format.
Further, please refer to fig. 12, which is a schematic structural diagram of another data processing apparatus according to an embodiment of the present invention. As shown in fig. 12, the data processing apparatus 1000 may be applied to the rendering terminal 3000 in the embodiment corresponding to fig. 1, where the data processing apparatus 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display) and a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a standard wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 12, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the data processing apparatus 1000 shown in fig. 12, the network interface 1004 is mainly used to provide a network communication function; the user interface 1003 is an interface for providing a user with input; and the processor 1001 may be used to invoke a device control application stored in the memory 1005 to implement:
acquiring format conversion demand information corresponding to original text information, acquiring a target data format in the format conversion demand information, and acquiring an original key field contained in the original text information;
acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
It should be understood that the data processing apparatus 1000 described in the embodiment of the present invention may perform the description of the data processing method in the embodiment corresponding to fig. 2, fig. 6, or fig. 8, and may also perform the description of the data processing apparatus 1 in the embodiment corresponding to fig. 11, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, here, it is to be noted that: an embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores the aforementioned computer program executed by the data processing apparatus 1, and the computer program includes program instructions, and when the processor executes the program instructions, the description of the data processing method in the embodiment corresponding to fig. 2, fig. 6, or fig. 8 can be executed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in the embodiments of the computer storage medium to which the present invention relates, reference is made to the description of the method embodiments of the present invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (15)

1. A data processing method, comprising:
acquiring format conversion demand information corresponding to original text information, acquiring a target data format in the format conversion demand information, and acquiring an original key field contained in the original text information;
acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
2. The method according to claim 1, wherein the obtaining a configuration template corresponding to the original text information based on the target data format and the original key field comprises:
if the target data format comprises a format rendering type and a data output sequence corresponding to the original key field, determining that the format rendering type is a first rendering type, and traversing and searching a configuration template to be matched, which contains the original key field and has the first rendering type, in a configuration library;
and in the configuration templates to be matched, taking the configuration templates to be matched which are consistent with the data output sequence as the configuration templates corresponding to the original text information.
3. The method of claim 2, wherein traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information having the target data format according to the configuration template and the key value comprises:
analyzing the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
determining the template key fields as first fields to be rendered, traversing and searching original key fields which are the same as the first fields to be rendered in the original text information, acquiring key values corresponding to the searched original key fields, and taking the key values as rendering output results corresponding to the first fields to be rendered based on the first rendering type;
and integrating the plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
4. The method according to claim 1, wherein the obtaining a configuration template corresponding to the original text information based on the target data format and the original key field comprises:
if the target data format comprises a format rendering type and a data output sequence corresponding to a target key field, determining that the format rendering type is a second rendering type, and extracting the target key field in the target data format;
traversing and searching a configuration template to be matched, which comprises the target key field and the original key field, in a configuration library according to the second rendering type;
and in the configuration templates to be matched, taking the configuration templates to be matched which are consistent with the data output sequence as the configuration templates corresponding to the original text information.
5. The method of claim 4, wherein traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information having the target data format according to the configuration template and the key value comprises:
analyzing the configuration template; the format rendering type of the configuration template is the second rendering type;
and converting the original key field into a target key field with the target data format according to the second rendering type, and assigning a value to the target key field according to a key value corresponding to the original key field to obtain target text information.
6. The method according to claim 5, wherein the converting the original key field into a target key field having the target data format according to the second rendering type, and assigning a value to the target key field according to a key value corresponding to the original key field to obtain target text information comprises:
acquiring a plurality of template key fields corresponding to the configuration template; each template key field consists of the original key field and the target key field;
determining the template key fields as second fields to be rendered, traversing and searching the original key fields contained in the second fields to be rendered in the original text information, acquiring key values corresponding to the searched original key fields, and taking the key values as target values corresponding to target key fields in the second fields to be rendered;
carrying out format configuration on the target key field and the target value based on the second format rendering type, and taking the target key field and the target value after format configuration as rendering output results corresponding to the second field to be rendered;
and integrating a plurality of rendering output results according to the data output sequence, and determining the plurality of integrated rendering output results as target text information with the target data format.
7. The method according to claim 1, wherein the obtaining a configuration template corresponding to the original text information based on the target data format and the original key field comprises:
if the target data format comprises a format rendering type corresponding to the original key field, taking the format rendering type as a first rendering type, and determining that a field configuration mode corresponding to the first rendering type is a first configuration mode;
carrying out format configuration on the original key field in the original text information, and converting the original key field after format configuration into a template key field according to the first configuration mode;
and generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
8. The method according to claim 1, wherein the obtaining a configuration template corresponding to the original text information based on the target data format and the original key field comprises:
if the target data format comprises a format rendering type corresponding to the target key field, taking the format rendering type as a second rendering type, and determining that a field configuration mode corresponding to the second rendering type is a second configuration mode;
extracting target key fields in the target data format, and carrying out format configuration on the original key fields in the original text information;
combining the original key field and the target key field after format configuration according to the second configuration mode to generate a template key field;
and generating a configuration template corresponding to the original text information according to the template key field and the data output sequence in the target data format.
9. The method according to claim 1, wherein said obtaining the original key field contained in the original text message comprises:
and screening all original key fields in the original text information according to the format conversion requirement information, and determining the screened original key fields as original key fields for generating target text information.
10. A data processing apparatus, comprising:
the first acquisition module is used for acquiring format conversion demand information corresponding to original text information and acquiring a target data format in the format conversion demand information;
the second acquisition module is used for acquiring an original key field contained in the original text information;
the template acquisition module is used for acquiring a configuration template corresponding to the original text information based on the target data format and the original key field;
and the information conversion module is used for traversing the original text information based on the configuration template to obtain a key value corresponding to the original key field, and converting the original text information into target text information with the target data format according to the configuration template and the key value.
11. The apparatus of claim 10, wherein the template acquisition module comprises:
a first template searching unit, configured to determine that the format rendering type is a first rendering type if the target data format includes the format rendering type and the data output order corresponding to the original key field, and search, in a configuration library, a configuration template to be matched, which includes the original key field and has the first rendering type, in a traversal manner;
and the first template determining unit is used for taking the configuration template to be matched, which is consistent with the data output sequence, as the configuration template corresponding to the original text information in the configuration templates to be matched.
12. The apparatus of claim 11, wherein the information conversion module comprises:
the first template analysis unit is used for analyzing the configuration template to obtain a plurality of template key fields corresponding to the configuration template; the format rendering type of the configuration template is the first rendering type; each template key field is composed of the original key field;
a first rendering unit, configured to determine the template key fields as a first field to be rendered, search, in the original text information, an original key field that is the same as the first field to be rendered, obtain a key value corresponding to the searched original key field, and use the key value as a rendering output result corresponding to the first field to be rendered based on the first rendering type;
and the target determining unit is used for integrating the rendering output results according to the data output sequence and determining the integrated rendering output results as target text information with the target data format.
13. The apparatus of claim 10, wherein the template acquisition module comprises:
the target field extraction unit is used for determining that the format rendering type is a second rendering type if the target data format comprises a format rendering type and a data output sequence corresponding to a target key field, and extracting the target key field in the target data format;
a second template searching unit, configured to search, in a configuration library, a configuration template to be matched, which includes the target key field and the original key field, in a traversal manner according to the second rendering type;
and the second template determining unit is used for taking the configuration template to be matched, which is consistent with the data output sequence, as the configuration template corresponding to the original text information in the configuration templates to be matched.
14. A data processing apparatus, comprising: a processor and a memory;
the processor is coupled to the memory, wherein the memory is configured to store program code and the processor is configured to invoke the program code to perform the method of any of claims 1-9.
15. A computer storage medium, characterized in that the computer storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method according to any one of claims 1-9.
CN201810689187.9A 2018-06-28 2018-06-28 Data processing method and device Active CN110727417B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810689187.9A CN110727417B (en) 2018-06-28 2018-06-28 Data processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810689187.9A CN110727417B (en) 2018-06-28 2018-06-28 Data processing method and device

Publications (2)

Publication Number Publication Date
CN110727417A true CN110727417A (en) 2020-01-24
CN110727417B CN110727417B (en) 2024-03-15

Family

ID=69216715

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810689187.9A Active CN110727417B (en) 2018-06-28 2018-06-28 Data processing method and device

Country Status (1)

Country Link
CN (1) CN110727417B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026338A (en) * 2019-11-14 2020-04-17 用友网络科技股份有限公司 Printing method, printing device and storage medium based on editable template
CN112217896A (en) * 2020-10-13 2021-01-12 北京思特奇信息技术股份有限公司 JSON message conversion method and related device
CN112379949A (en) * 2021-01-14 2021-02-19 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium
CN114115652A (en) * 2020-08-10 2022-03-01 腾讯科技(武汉)有限公司 Information display method, device, equipment and storage medium
CN115858457A (en) * 2023-02-09 2023-03-28 中航金网(北京)电子商务有限公司 File conversion method and device and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843878A (en) * 2016-03-17 2016-08-10 杭州优云软件有限公司 IT system event standardization realization method
WO2017084515A1 (en) * 2015-11-16 2017-05-26 中兴通讯股份有限公司 Method and device for transmitting data code stream
CN107025125A (en) * 2016-01-29 2017-08-08 上海大唐移动通信设备有限公司 A kind of source code flow coding/decoding method and system
CN108052320A (en) * 2017-12-11 2018-05-18 上证所信息网络有限公司 A kind of method that binary structure body is converted to JSON objects

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017084515A1 (en) * 2015-11-16 2017-05-26 中兴通讯股份有限公司 Method and device for transmitting data code stream
CN107025125A (en) * 2016-01-29 2017-08-08 上海大唐移动通信设备有限公司 A kind of source code flow coding/decoding method and system
CN105843878A (en) * 2016-03-17 2016-08-10 杭州优云软件有限公司 IT system event standardization realization method
CN108052320A (en) * 2017-12-11 2018-05-18 上证所信息网络有限公司 A kind of method that binary structure body is converted to JSON objects

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026338A (en) * 2019-11-14 2020-04-17 用友网络科技股份有限公司 Printing method, printing device and storage medium based on editable template
CN111026338B (en) * 2019-11-14 2023-10-03 用友网络科技股份有限公司 Printing method, printing device and storage medium based on editable template
CN114115652A (en) * 2020-08-10 2022-03-01 腾讯科技(武汉)有限公司 Information display method, device, equipment and storage medium
CN112217896A (en) * 2020-10-13 2021-01-12 北京思特奇信息技术股份有限公司 JSON message conversion method and related device
CN112379949A (en) * 2021-01-14 2021-02-19 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium
CN115858457A (en) * 2023-02-09 2023-03-28 中航金网(北京)电子商务有限公司 File conversion method and device and electronic equipment

Also Published As

Publication number Publication date
CN110727417B (en) 2024-03-15

Similar Documents

Publication Publication Date Title
CN110727417B (en) Data processing method and device
CN110198247B (en) Interface test method and system
US9239705B2 (en) Method and apparatus for customized software development kit (SDK) generation
CN104112002B (en) A kind of methods, devices and systems of list adaptation
US10574724B2 (en) Automatic discovery of management nodes and generation of CLI using HA module
CN111683066B (en) Heterogeneous system integration method, heterogeneous system integration device, computer equipment and storage medium
US10754628B2 (en) Extracting web API endpoint data from source code to identify potential security threats
US20190102465A1 (en) Api query extension
CN113778897B (en) Automatic test method, device and equipment for interface and storage medium
CN111274781A (en) Table display method and device, storage medium and electronic equipment
CN114461955A (en) Method for automatically generating http interface based on web page configuration
CN116931910A (en) Development method and device based on protocol framework, electronic equipment and storage medium
US20200110584A1 (en) Automated code generation for functional testing of software applications
CN113268232B (en) Page skin generation method and device and computer readable storage medium
CN109068170B (en) Storage method, device, terminal and storage medium for barrage message
US12001458B2 (en) Multi-cloud object store access
CN112948264B (en) Method and device for executing test task, system, storage medium and electronic device
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
US20190121649A1 (en) User interface metadata from an application program interface
CN111985186B (en) Dictionary item conversion method, API gateway system, equipment and storage medium
CN114817794A (en) Webpage content control method, device, equipment and medium
CN112492353B (en) Processing method, device, equipment and storage medium for data in live broadcasting room
CN111142846B (en) Component development method, device and system, mobile terminal and readable storage medium
US11803549B2 (en) Method and system for facilitating on-the-fly OVSDB protocol translation between multiple OVSDB schema versions
CN114385175A (en) Code generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40018774

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant