CN110727417B - Data processing method and device - Google Patents

Data processing method and device Download PDF

Info

Publication number
CN110727417B
CN110727417B CN201810689187.9A CN201810689187A CN110727417B CN 110727417 B CN110727417 B CN 110727417B CN 201810689187 A CN201810689187 A CN 201810689187A CN 110727417 B CN110727417 B CN 110727417B
Authority
CN
China
Prior art keywords
original
target
format
template
text information
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.)
Active
Application number
CN201810689187.9A
Other languages
Chinese (zh)
Other versions
CN110727417A (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

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

Abstract

The embodiment of the invention discloses a data processing method, which comprises the following steps: 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; 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 of APP (Application), a network communication module is generally used, and the network communication module may be used to transfer json (JavaScript Object Notation ) data through HTTP (Hyper Text Transport Protocol, hypertext transfer protocol).
Currently, when a terminal receives json data, a developer is often required to analyze the received json data according to a specific data interface. Then, the parsed json data is artificially subjected to data reconstruction according to a specified data format to obtain target data. It can be seen that the conversion efficiency of the data format is reduced by this manual operation.
Disclosure of Invention
The embodiment of the invention provides a data processing method and a data processing device, which can improve the conversion efficiency of a data format.
In one aspect, the present invention provides a data processing method, including:
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;
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.
The obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to the original key field, determining the format rendering type as a first rendering type, and traversing and searching a configuration template to be matched, wherein the configuration template comprises the original key field and has the first rendering type, in a configuration library;
and taking the configuration templates to be matched, which are consistent with the data output sequence, as configuration templates corresponding to the original text information.
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 traversing comprises the steps of:
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 plurality of 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 types;
integrating the multiple rendering output results according to the data output sequence, and determining the integrated multiple rendering output results as target text information with the target data format.
The obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to the target key field, determining the format rendering type as 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 contains the target key field and the original key field, in a configuration library according to the second rendering type;
And taking the configuration templates to be matched, which are consistent with the data output sequence, as configuration templates corresponding to the original text information.
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 traversing comprises the steps of:
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.
The step of 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, including:
Acquiring a plurality of template key fields corresponding to the configuration template; each template key field is composed of the original key field and the target key field;
determining the plurality of template key fields as second to-be-rendered fields, traversing and searching the original key fields contained in the second to-be-rendered fields 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 to-be-rendered fields;
performing 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;
integrating the multiple rendering output results according to the data output sequence, and determining the integrated multiple rendering output results as target text information with the target data format.
The obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information 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;
performing format configuration on the original key fields in the original text information, and converting the original key fields after format configuration into template key fields 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.
The obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information 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 a target key field in the target data format, and carrying out format configuration on the original key field 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.
The obtaining the original key field contained 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.
In one aspect, the present invention provides a data processing apparatus comprising:
the first acquisition module is used for acquiring format conversion requirement information corresponding to the original text information and acquiring a target data format in the format conversion requirement information;
the second acquisition module is used for acquiring the original key fields 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;
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 includes:
the first template searching unit is used for determining the format rendering type as a first rendering type if the target data format comprises the format rendering type and the data output sequence corresponding to the original key field, 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;
the first template determining unit is used for 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 information conversion module includes:
the first template analyzing 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;
The first rendering unit is used for determining the plurality of 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 the target determining unit is used for integrating the 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.
Wherein, the template acquisition module includes:
a target field extraction unit, 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 is used for traversing and searching the configuration templates to be matched, which contain the target key field and the original key field, in a configuration library according to the second rendering type;
And the second template determining unit is used for 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 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 acquisition subunit, configured to acquire a plurality of template key fields corresponding to the configuration template; each template key field is composed of the original key field and the target key field;
the rendering subunit is used for determining the plurality of 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;
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 integration subunit is used for integrating the plurality of rendering output results according to the data output sequence and determining the integrated plurality of rendering output results as target text information with the target data format.
Wherein, the template acquisition module includes:
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 fields in the original text information and converting the original key fields after format configuration into template key fields according to the first configuration mode;
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 includes:
a second mode determining unit, configured to, if the target data format includes a format rendering type corresponding to the target key field, take 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 target key fields in the target data format and carrying out format configuration on the original key fields 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, so as to 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 for generating target text information.
An aspect of the present invention provides a data processing apparatus, comprising: a processor and a memory;
the processor is connected to a memory, where the memory is configured to store program code, and the processor is configured to invoke the program code to perform the method according to the above aspect of the embodiments of the present invention.
An aspect of the present invention provides a computer storage medium storing a computer program comprising program instructions which, when executed by a processor, perform a method according to the above aspect of the embodiments of the present invention.
When the format conversion requirement information corresponding to the original text information is obtained, the embodiment of the invention can further obtain the target data format in the format conversion requirement information and obtain the original key field contained in the original text information; then, further based on the target data format and the original key field, acquiring a configuration template corresponding to the original text information; and finally, 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. In the conversion process of 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, namely, the key value corresponding to the original key field can be rapidly acquired according to the configuration template, so that the target text information with the specified data format is output. In view of this, through this configuration template can be fast with the key value transmission in the original text information to the target text information, and improve the conversion mechanism of data format, need not to carry out the data reconstruction by people promptly, thereby can improve data format's conversion efficiency.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic structural diagram of a network architecture according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a data processing method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of screening valid original key fields according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a search configuration template provided by an embodiment of the present invention;
FIG. 5 is a schematic diagram of another lookup configuration template provided by an embodiment of the present invention;
FIG. 6 is a flowchart of 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 flowchart of another data processing method according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of another generation of target text information according to an embodiment of the present invention;
FIG. 10 is a method for recursively calling a rendering function provided by an embodiment of the present invention;
FIG. 11 is a schematic 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 following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the 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 client terminals 4000a, 4000b, …, and 4000n;
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), where each data source corresponds to a designated data interface, and it should be understood that the data interfaces may be used 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, raw text information corresponding to the data interface may be obtained from the service terminal 2000 according to the data interface.
The client terminals 4000a, 4000b, …, 4000n may be respectively connected to the rendering terminal 3000 via a network, and may receive the target text information with the target data format returned by the rendering terminal 3000. For better understanding of the present solution, an embodiment of the present invention may select one client terminal from the client terminal cluster shown in fig. 1 as a target client terminal (taking the target client terminal as the client terminal 4000a as an example), 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 the rendering terminal 3000 rendering the original text information according to a configuration template, that is, 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 through the configuration template. In order to facilitate understanding of the scheme, the embodiment of the invention can refer to the original text information with the json format as original json data and the target text information with the json format as target json data. It should be appreciated that the two json format data carry different names, respectively, to play different roles in different terminals.
It should be appreciated that any data that satisfies the json rule (i.e., data having a json format) may be referred to as json data. In javascript, the basic structure of json data can be understood as an object and an array, so that various complex structures can be represented by both structures (i.e., both the object and the array).
Wherein the object (object) can be understood as a set of "name/value" pairs (A collection of name/value pairs). It should be appreciated that in a different language, it may also be understood as a record (structure), a dictionary, a hash table (hash table), a keyed list, or an associative array (associative array). For example, the "name/value pair" may be represented in json format, { "first name": "Brett" };
wherein the array (array) can be understood as an ordered list of values (An 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 persons having the same attribute (i.e., attribute "scope"):
It should be appreciated that in this example there is only one variable named scope whose value is an array containing three entries, each entry being a person's record containing a first name, a last name and an email address. The above example demonstrates how the records are combined into one value in brackets. Of course, multiple values (each value containing multiple records) may be represented using the same syntax and will not be described in further detail herein.
It should be appreciated that json is a native format of JavaScript, meaning that no special APIs (Application Programming Interface, application program interface) or toolkits are required to process json formatted data in JavaScript. In JavaScript, a new JavaScript variable can be created, then the json format data is directly assigned to it to access the value in the JavaScript variable (e.g., a variable named peole with a first attribute can be traversed in JavaScript to find a variable named first name2 with a second attribute to access a person with a value of "Jason");
in addition, 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., the client terminal 4000 a) 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 key values in original text information to target text information having a target data format by means of a configuration template, that is, may realize separation of data and presentation.
It should be understood that the data format of the original data (i.e., the original data format corresponding to the original 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" }. It can be seen that the values of the two json objects are "charles", but are obviously different in the written json format, so that the rendering terminal 3000 can determine the mapping relationship between different names in the two json objects through a configuration template (for example, { "value": "data: name" }), thereby realizing separation of data and expression, and rapidly transmitting the key value of the json object in the original text information to the target text information, so that the conversion efficiency of the data format can be improved.
It should be appreciated that the target text information is used for data transmission between the background service terminal and the foreground terminal, i.e. the target text information may be returned to the target client terminal when the rendering terminal 3000 obtains the target text information. At this time, the target client terminal and the rendering terminal can recognize the target text information, so as to separate data and performance (namely, complete the transfer of data from the background logical page to the foreground display page). Accordingly, the rendering terminal 3000 may understand 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 easy understanding, in JavaScript, the rendering terminal 3000 may name the json object in the json format as obj 1= { "data": { "name": "charles" }, and { "data" in the json object: { "name" to "characters" } } is called the original text information (i.e., original json format data) carrying the original data format. The attributes of the character strings "data" and "name" are collectively called as the original key field of obj1 (json object), and the attribute of the character string "charles" is the key value of obj1 (json object), i.e. the key value corresponding to the original key field is "charles". In addition, the json object in the json format obtained after the conversion of the configuration template is named as obj2 = { "value": "charles" }, and { "value": "charles" } in the json object is named as target text information carrying target data format (namely target json format data). The attribute of the character string "value" is collectively called 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, so that a format conversion mechanism between different json format data can be improved, namely, the data reconstruction is not needed to be carried out manually, the conversion of multiple data formats is not needed, and the target json data which can be identified by the target client terminal can be obtained quickly.
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 be integrated in the rendering terminal. The specific existence forms of the rendering terminal 3000 and the configuration library 5000 and the server 2000 will not be limited here.
It should be understood that the configuration template may be understood as a configuration template to be matched that is already existing in the configuration repository 5000, that is, the rendering terminal 3000 may directly find the configuration template in the configuration repository 5000 according to the target data format and the original key field; of course, when the configuration template is not found, the rendering terminal 3000 may further generate the configuration template in real time according to the target data format and the original key field, and add the configuration template to the configuration library 5000, so as to facilitate the subsequent search of the configuration template according to the target data format and the original key field when format conversion requirement information (the format conversion requirement information carries the target data format) of the client terminal 4000a is received.
The target data format may include a format rendering type and a data output sequence corresponding to the original key field, so 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 the data source. At this time, in the configuration template, each template key field is composed of the original key field. Then, 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" satisfying the json format in the original text information according to the first rendering type, so as 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 sequence corresponding to the target key field, so 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 that makes a path in the 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. Then, 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 found 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 may further return the target text information having the target data format to the target client terminal (client terminal 4000 a) to enable the target client terminal to identify the target text information having the target data format.
The specific process of the rendering terminal 3000 obtaining the configuration template, obtaining the key value corresponding to the original key field, and rendering the original text information may be referred to as the following embodiments corresponding to fig. 2 to 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 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;
specifically, the rendering terminal may acquire 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 can be extracted by the rendering terminal when receiving a data conversion request sent by the client terminal, and optionally, the format conversion requirement information can also be data information directly sent by the client terminal; and then, the rendering terminal can 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 for generating the target text information, namely, the rendering terminal can 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 the target client terminal in the embodiment corresponding to fig. 1, where the client terminal may include a terminal device with a Web interface display function, such as a personal computer, a tablet computer, a notebook computer, an intelligent television, and a smart phone.
The format conversion requirement information is used for designating that the rendering terminal needs to output data with a designated 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, or alternatively, the rendering terminal may be required to extract data in a formulated path 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 render data according to the first rendering type or 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 sequence corresponding to the original key field, where the format rendering type of the configuration template may be referred to as a first rendering type, and the first rendering type is used for outputting data of a certain field in the data source. In the configuration template, each template key field is composed of the original key field. Therefore, the rendering terminal may output, according to the configuration template, a key value corresponding to an original key field in a data source (i.e., original text information), that is, the rendering terminal may separate, according to the first rendering type, a "name/value pair" satisfying a json format in the original text information, so as to obtain a value corresponding to a name in each json format.
Optionally, the target data format may also include a format rendering type and a data output sequence corresponding to the target key field, where 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 that makes a path in the data source. Further, in the configuration template, each template key field is composed of 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, so as to obtain target text information, thereby realizing separation of data and expression.
For easy understanding, the embodiment of the invention takes an original data format corresponding to the original text information as an example, wherein the original text information can be written as { "ret":0}, wherein { "ret":0} is a json object, and can represent a "name/value pair", the attribute of the character string "ret" in the json object can be understood as an original key field in the original text information, and the numerical value 0 is a key value of the json object.
A json object may be understood as an unordered set of "" name/value' pairs "". The writing format of the json object is as follows: starting with "{" (left brackets) and ending with "}" (right brackets). Each "name" is followed by one ": (colon); the ""' name/value "pair is used" between "" (comma) separations.
It should be understood that, when receiving a designated data interface, that is, a data source interface entered by a developer, the rendering terminal may pull corresponding original text information from the server or receive the original text information pushed by the server according to the data interface. And secondly, the rendering terminal can further screen all original key fields in the original text information according to the format conversion requirement information so as to obtain effective original key fields, namely the original key fields which can be used for generating the target text information.
Further, please refer to fig. 3, which is a schematic diagram illustrating screening of valid original key fields according to an embodiment of the present invention. As shown in fig. 3, the original text information with json format 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:
Thus, the names in the registration information can be understood as the original key fields shown in fig. 3. At this time, if the user named Brett and Jason is live broadcasting using the video application a, and the client terminal needs to check the current use situation of the video application a, that is, the client terminal may require the rendering terminal to output, in json format, the user information (for example, the login name and login password of the online user) of the current login to the video application a. 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, that is, "loading_name" and "pass_word". Therefore, the rendering terminal may further screen out the online registered user data 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 for generating the target text information. It should be appreciated that the symbols X1 and X2 may represent the identity of the user currently using the video application A, and that the symbols Y1, Y2 and Y3 may represent the identity of the offline user to which the video application A corresponds. Therefore, the effective original key fields extracted by the rendering terminal may be: the information of registered users with the user names of Brett and Jason, namely, the rendering terminal can filter all original key fields according to the format conversion requirement information to obtain two original key fields as shown in fig. 3, wherein the original key field X1 can be "Name1" and "Value1", and the original key field X2 can be "Name2" and "Value 2"). For ease of understanding, the json data corresponding to these two valid original key fields may be referred to as sub-data of the original json data, and thus, the sub-data may be:
As can be seen, the specific process of the rendering terminal obtaining the original key field included in the original text information may be understood as that in the original text information, the original text information is filtered according to the format conversion requirement information, so as to obtain an effective original key field, so that step S102 and step S103 are further performed. It should be understood that the sub-data may be understood as a virtually existing data, and in actual applications, the sub-data may be referred to as json data 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, when the configuration template corresponding to the original text information is not found, the rendering terminal may generate the configuration template corresponding to the original text information according to the target data format and the original key field.
The configuration template can reflect the data mapping relation between the original text information and the target text information.
If the target data format includes a format rendering type and a 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, and in a configuration library, traverse and find a configuration template to be matched including the original key field and having the first rendering type, and in the configuration template to be matched, use a configuration template to be matched, which is consistent with the data output sequence, as a 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": "characters", "value2": "marry" }, i.e. the original text information is the original text data 10 as shown in fig. 4, the original text data 10 may be referred to as the original json data 10. As shown in fig. 4, the original key fields 101 in the original text information are: "data", "stats", "value1", and "value2", wherein the string "data" is the name of the top-level field in the original json data 10, so the field "data" may be referred to as the original key field with the first attribute (i.e., the top-level field in the original json data 10 may be referred to as the parent node), whose value is a set of "name/value pairs", i.e., the string { "stats": "complete", "value1": "charles", "value2": "marry" is the value of field "data". Wherein, the set of "name/value pairs" is composed of three "name/value pairs", the field "stats", the field "value1" and the field "value2" each have a parent-child node relationship with the field "data", and thus, these three fields (i.e., the field "stats", the field "value1" and the field "value 2") can be referred to as the original key field having the second attribute. That is, the original key field 101 as shown in fig. 4 may include an original key field having a first attribute and having a second attribute. In the set of "name/value pairs", 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 values 102 in the original json data 10 may include: "complex", "charles" and "marry".
If the client terminal requests the rendering terminal to sequentially output the key values 102 of the original json data 10, that is, the format conversion requirement information received by the rendering terminal is format conversion requirement information 20 as shown in fig. 4, the format conversion requirement information 20 may be the key values 102 of the original json data 10 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, which may be understood as 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 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 perform a traversal search in the configuration library 30 for the configuration template to be matched including the original key field 101, and the configuration template to be matched has the first rendering type, that is, the rendering terminal may perform a traversal search in the configuration library for the configuration template to be matched including the original key field 101 according to the first rendering type. In other words, the rendering terminal may traverse the configuration library 30 for a configuration template to be matched containing the four original key fields (i.e. "data", "stats", "value1" and "value 2"), where 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 the configuration template to be matched (for example, format 1) corresponding to the data output sequence as the configuration template corresponding to the original text information (that is, the configuration template may be the configuration template 301 as shown in fig. 4) in the three configuration templates to be matched.
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 (i.e., does not find the configuration template with the data Format of Format 1), the rendering terminal may further acquire the field configuration mode corresponding to the first rendering type, take the acquired field configuration mode as the first configuration mode, 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 acquiring a key value. Secondly, the rendering terminal may convert the original key field 101 after format configuration into a template key field according to the first configuration mode, that is, determine a field in the rendering path as a template key field of the configuration template according to the first configuration mode, and then, the rendering terminal may further generate a configuration template corresponding to the original text information (that is, the configuration template 301 as illustrated in fig. 4) 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 the format rendering type as a second rendering type, extracting the target key field in the target data format, traversing and searching a configuration template to be matched including the target key field and the original key field in a configuration library according to the second rendering type, and using 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 template to be matched.
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": "characters", "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 fields 401 in the original text information are: "message", "stats", "value1", and "value2", wherein the field "message" is the name of the top-level field in the original json data 40, and thus the field "data" may be referred to as the original key field with the first attribute (i.e., the top-level field in the original json data 40 may be referred to as the parent node), whose value is a set of "name/value pairs", i.e., the string { "stats": "complete", "value1" to "characters", "value2" to "marry" is the value of the field "message". Wherein the set of "name/value pairs" is composed of three "name/value pairs", the field "stats", the field "value1" and the field "value2" have parent-child node relationships with the field "message", respectively, and thus, these three fields (i.e., the field "stats", the field "value1" and the field "value 2") may be referred to as original key fields having the second attribute, i.e., the original key field 401 as shown in fig. 5 may include, i.e., the original key fields having the first attribute and having the second attribute. In the set of "name/value pairs", 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 values 402 in the original json data 40 may include: "complex", "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 order 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 a 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. Secondly, the rendering terminal may traverse and search the configuration templates to be matched including the target key field 60 and the original key field 401 in 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. The data format of the configuration template to be matched can 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 the configuration template to be matched (for example, format 2) corresponding to the data output sequence 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) in the three configuration templates to be matched.
Optionally, when the rendering terminal does not find a configuration template corresponding to the original json data 40 in the configuration library 70 (i.e. does not find a configuration template with a 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, take the obtained field configuration mode as a 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 (i.e. the target key field 60 and the fields in the rendering path form a set of "name/value pairs" according to json rules), so as 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 corresponding to the original text information (i.e., the configuration template 302 shown in fig. 5) according to the key field of the template and the data output sequence in the target data format.
For example, the data format of the generated configuration template may be: format 2= { "stats": "message: stats", "second": "message: value2", "first": "message: value1" }.
It should be understood that, before the rendering terminal generates the configuration template, the original key field with the first attribute and the original key field with the second attribute may be configured in advance, that is, the original key field after the configuration is converted into a rendering path for obtaining a key value, that is, the rendering path is formed by the original key field with a parent-child node relationship, so the rendering path may be a character string "message: stats", "message: value1", "message: value2". The field data is the name of the top field in the original json data, so the rendering path message: stats may represent the stats 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 the format conversion requirement information, that is, the rendering terminal may combine the original key field (i.e., the field in the rendering path) after the format configuration and the target key field according to the second configuration manner, so as to further generate a template key field.
The configuration library may be the configuration library 5000 in the embodiment corresponding to fig. 1, where a plurality of configuration templates exist in the configuration library, and each configuration template corresponds to one format conversion requirement information. Furthermore, 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 be a rendering type of other formats besides the first rendering type and the second rendering type, and the format rendering type will not be particularly limited herein.
Thus, 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. Then, when the rendering terminal obtains the original json data, the rendering terminal may further render the original json data through the searched configuration template, that is, may further execute step S103 to convert the original json data into target data having a target data format (for example, may convert the original json data 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 parse the 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 the 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, taking the key values as rendering output results corresponding to the first fields to be rendered based on the first rendering type, and then integrating the plurality of rendering output results according to the data output sequence by the rendering terminal, and determining the integrated plurality of rendering output results as target text information with the target data format. Optionally, after the parsing of 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 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, so as to obtain target text information.
In the process of obtaining the key value in the original json data, the rendering terminal may take the template key field as a 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 traverse each original key field 101 in the original text information according to the field in the rendering path of the first field to be rendered (i.e., the field data and the field stats in the configuration template shown in fig. 4) when the format rendering type is the first rendering type, so as to search the original key field 101 identical to the first field to be rendered in the original text information, thereby obtaining the key value 102 corresponding to the searched original key field 101 (i.e., the key value is complete), and then the rendering terminal may further take the obtained key value 102 as the 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 simply acquires the key value 102 in the original json data through the configuration template 301, so the rendering terminal may further integrate a plurality of rendering output results according to the data output order, and determine the integrated plurality of rendering output results as the target text information having the target data format.
Optionally, in the process of obtaining the key value 102 in the original json data 10, the rendering terminal may 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, the field data with the first attribute is found first, and then the field stats with the second attribute under the field data is further found, 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 with 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 target text information.
When the format conversion requirement information corresponding to the original text information is obtained, the embodiment of the invention can further obtain the target data format in the format conversion requirement information and obtain the original key field contained in the original text information; then, further based on the target data format and the original key field, acquiring a configuration template corresponding to the original text information; and finally, 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. In the conversion process of 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, namely, the key value corresponding to the original key field can be rapidly acquired according to the configuration template, so that the target text information with the specified data format is output. In view of this, through this configuration template can be fast with the key value transmission in the original text information to the target text information, and improve the conversion mechanism of data format, need not to carry out the data reconstruction by people promptly, thereby can improve data format's conversion efficiency.
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, obtaining format conversion requirement information corresponding to original text information, obtaining a target data format in the format conversion requirement information, and obtaining 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 json format, so if the format conversion requirement information acquired by the rendering terminal is a key value in the original json data output according to a target data format (i.e. a designated data format), the rendering terminal may explicitly include: the format rendering type and the data output sequence corresponding to the original key field.
Optionally, the format conversion requirement information may further be that a value in the formulated path is extracted to a target key field according to a target data format (i.e. 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 an obtained value in the formulated path), and the rendering terminal may explicitly include: the format rendering type and the data output sequence corresponding to the target key field. The value in the formulated path is the 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 configured to output the key value in the original json data 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: 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 a first rendering type as shown in fig. 7, and the first rendering type can be understood as a rendering algorithm corresponding to the configuration template 201a, through which original text information having a json format (i.e., the original text data 3a shown in fig. 7, the original text data 3a may be the original json data 3 a) can be converted into target text information having a target data format (i.e., the target text information 4a shown in fig. 7).
As shown in fig. 7, the rendering terminal obtains two original key fields (the two original key fields may be referred to as the original key fields 301a shown in fig. 7) from the original json data 3a obtained by the rendering terminal (the rendering terminal may refer to the original json data 3a as original text information) as { "data": { "name": "value" }. Where the original key field 301a is a field "data" and a field "name", it should be understood that the field "data" is the name of the top-level field in the original json data 3a, that is, the top-level field "data" may be referred to as a parent node in the original json data 3a, so the field "data" may be referred to as an original key field having a first attribute, and its value is a "name/value pair", that is, the string { "name": "value" } is the value of the field "data". Since the field "name" is a field under the field "data", i.e., the field "name" has a parent-child node relationship with the field "data", the field "name" may be referred to as an original key field having a second attribute, where the character string "value" is a value of the field "name". Then, the rendering terminal may take the value of the field "name" under the field "data" (i.e., "value") 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, wherein the configuration template comprises the original key field and has the first rendering type, in a configuration library;
specifically, after the rendering terminal performs the step S201, the obtained parameter content carried in the target data format may be further extracted to obtain a format rendering type and a data output sequence corresponding to the original key field, where the rendering terminal may determine that the target data format does not include the target key field, that is, does not need to output a "name/value pair" according to the 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 can further search a configuration template to be matched containing the original key field in a configuration library according to the first rendering type.
The configuration library shown may be the configuration library 2a shown in fig. 7, so the rendering terminal may find a configuration template to be matched containing the original key field 2a in the configuration library 2 a. Since the original key field 301a is the field "data" and the field "name" as shown in fig. 7, the data format of the configuration template to be matched may be: format = data: a name; wherein, the character string data: the name may be understood as a rendering path, and the fields in the rendering path are data and name, i.e. the fields in the rendering path may be referred to as a template key field of the configuration template, where the template key field is composed of original key fields.
It should be appreciated that there may be multiple configuration templates in the configuration library 2a, one for each format conversion requirement information. Therefore, when receiving the format conversion requirement information, the rendering terminal can further determine 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 to convert the original text information with the original json format 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 the format conversion requirement information a, or may convert json format X into format Z according to the format conversion requirement information B. The format conversion requirement information a and the format conversion requirement information B are two different requirement information, so that the rendering terminal can obtain target text information with different target data formats according to the different requirement information.
And step 203, 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 template to be matched.
Since the original json data 3a shown in fig. 7 is { "data" { "name": value "}, that is, the original json data 3a contains only 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 with the unique rendering path as the configuration template 302a corresponding to the original text information, so as to further execute the subsequent step S204-step S206, so as to quickly obtain the obtained character string value from the original json data 3a, where the character 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, and 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 to-be-matched template from the two to-be-matched configuration templates according to the data output sequence as the configuration template corresponding to the original json data, so as to further execute steps S204-S206, so that the rendering terminal can further quickly obtain 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 through the 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 appreciated that the stencil key field is a field in the rendering path, i.e., the stencil key fields are "data" and "name1", "data" and "name2". The character string data: name1 in the configuration template can be understood as a rendering path corresponding to the original key fields ("data" and "name 1"), and similarly, the character string data: name2 can be understood as a rendering path corresponding to the original key fields ("data" and "name 2").
Step S205, determining the plurality of 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 types;
at this time, the rendering terminal may use the plurality of template key fields obtained in step S204 together as the first field to be rendered, that is, the first field to be rendered is:
"data" and "name1";
"data" and "name2".
Then, the rendering terminal may further traverse each original key field in the original text information based on the first field to be rendered, so as to find the same original key field as the first field to be rendered, and obtain a key value corresponding to the found original key field, since the original json data is { "data": { "name1": "charles", "name2": "marry" }, the key value corresponding to each original key field obtained by the rendering terminal through the configuration template may be: charles, marry. And then, the rendering terminal can respectively take each key value as a rendering output result corresponding to the first field to be rendered according to the first rendering type.
Step S206, integrating the multiple rendering output results according to the data output sequence, and determining the integrated multiple rendering output results as target text information with the target data format.
As shown in fig. 7, if the data output sequence is that each rendering output result is output in 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 application, it may be a rendering function that recursively invokes itself). When the rendering function is called, all elements in the configuration template (the elements may be rendering paths in the configuration template) may be traversed, that is, the rendering terminal may take a plurality of template key fields (i.e., fields in the rendering paths) in the configuration template as a first field to be rendered, search for an original key field identical to the first field to be rendered in the original text information, take a key value corresponding to the original key field as a rendering output result, and integrate the plurality of rendering output results according to the data output sequence, so as to obtain target text information with the target data format, that is, realize outputting a value in original json data.
When the format conversion requirement information corresponding to the original text information is obtained, the embodiment of the invention can further obtain the target data format in the format conversion requirement information and obtain the original key field contained in the original text information; then, further based on the target data format and the original key field, acquiring a configuration template corresponding to the original text information; and finally, 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. In the conversion process of 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, namely, the key value corresponding to the original key field can be rapidly acquired according to the configuration template, so that the target text information with the specified data format is output. In view of this, through this configuration template can be fast with the key value transmission in the original text information to the target text information, and improve the conversion mechanism of data format, need not to carry out the data reconstruction by people promptly, thereby can improve data format's conversion efficiency.
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, obtaining format conversion requirement information corresponding to original text information, obtaining a target data format in the format conversion requirement information, and obtaining an original key field contained in the original text information;
further, for better understanding of the present solution, please refer to fig. 9, which is a schematic diagram of another generation of target text information according to an embodiment of the present invention. As shown in fig. 9, the format conversion requirement information 1b is configured to output a target key field and a target value corresponding to the target key field according to a target data format (the target value is a value in an acquired formulated path, and the value in the formulated path is a key value 302b acquired from the original json data 3 b), and the rendering terminal may determine that the target data format includes: the format rendering type and data output order corresponding to the target key field 101 b. The format rendering type corresponding to the target key field 101b is a second rendering type as shown in fig. 9, which can be understood as a rendering algorithm corresponding to the configuration template 201b, by which the original text information having the json format (i.e., the original text data 3b shown in fig. 9, which original text data 3b can be referred to as the original json data 3 b) can be converted into the target text information having the target data format (i.e., the target text information 4b shown in fig. 9).
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": "msg": "success" }, since the original json data 3b includes three sets of "name/value pairs", the rendering terminal further needs to screen the plurality of original key fields in the original json data 3b according to the format conversion requirement information 1b to obtain an effective original key field, that is, the rendering terminal may determine the effective "name/value pair" in the sets of three "name/value pairs", that is, 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 the 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 refer to the specific process of screening the valid original key fields in the embodiment corresponding to fig. 3, which will not be described in detail here.
For example, the original key fields in the two "name/value pairs" in the original json data 3b (data: { "name": "charles" } and "ret": 0) may be determined as valid original key fields, which are the original key fields used to obtain 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 the target text information.
It should be appreciated 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 field in the first "name/value pair" is a field "data" and a field "name", and the field "data" is the name of the top field in the original json data, so the field "data" may be referred to as an original key field with the first attribute (i.e., the top field in the first "name/value pair" may be referred to as a parent node), and its value is a "name/value pair", i.e., the string { "name": "value" } is the value of the field "data". The field "name" is a field under the field "data", and thus, the field "name" may be referred to as an original key field having the second attribute (i.e., there is a parent-child node 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 of the field "name" under the field "data" (i.e., "value") as a key value of the original json data 3b, i.e., when the original key fields are "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 "ret" then the key values 302b as shown in FIG. 9 may be: the string "value" and a value of 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 the format rendering type as a second rendering type, and extracting the target key field in the target data format;
specifically, after the rendering terminal performs the step S301, the obtained parameter content carried in the target data format may be further extracted, so as to obtain a format rendering type and a data output sequence corresponding to the target key field 101b, where the rendering terminal may determine that the target data format includes the target key field 101b. 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, traversing and searching a configuration template to be matched containing the target key field and the original key field in a configuration library according to the second rendering type.
The data format of the configuration template to be matched can 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 searching process of the configuration template to be matched may refer to the searching process of the configuration template to be matched in the embodiment corresponding to fig. 2, which will not be described in detail here.
Then, the rendering terminal needs to further execute step S304 to determine a configuration template corresponding to the original text information from a plurality of configuration templates to be matched according to the data output order.
Step S304, in the configuration templates to be matched, the configuration templates to be matched which are consistent with the data output sequence are used as 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 reverse order, that is, the data output order is that a plurality of rendering output results are output in reverse order, the first configuration template to be matched in the configuration templates to be matched 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: format 1= { "ERRCode": "ret", "value": "data: name" }.
Optionally, when the rendering terminal does not find a configuration template corresponding to the original json data in the configuration library (i.e. does not find a configuration template with a data Format of Format 1), the rendering terminal may further acquire a field configuration mode corresponding to the second rendering type, take the acquired field configuration mode as the second configuration mode, further extract the target key field 101b in the target data Format, which may be a field "error" and a 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 (i.e. ret and data: name) for acquiring a key value. And secondly, the rendering terminal can combine the original key field and the target key field after format configuration according to the second configuration mode (namely, the target key field and the fields in the rendering path form a set of 'name/value pairs' according to json rules) to generate a template key field, wherein 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. the configuration template 201b shown in fig. 9 may be obtained).
Thus, the data format of the generated configuration template 201b may be: format 1= { "ERRCode": "ret", "value": "data: name" }.
Step S305, analyzing the configuration template;
wherein it should be appreciated 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 "ERRCode" and "value" are names of output fields, namely, the target key field is the field "ERRCode" and the field "value", and the original key field is the field "ret", the field "data" and the field "name". It should be understood that in the configuration template 201b, each template may include multiple "name/value pair" sets, and thus, in the configuration template 201b, the value corresponding to the target key field may be a fixed rendering path or a json object including a certain rendering path.
Step S307, determining the plurality of template key fields as a second field to be rendered, traversing and searching the original key fields contained in the second field 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 field to be rendered;
Step S308, performing 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, the target key field and the target value are configured by writing the target key field 101b and the target value (the target value is the obtained key value 302b as shown in fig. 9) into a "name/value pair" with json format according to json rule, so that the target key field and the target value after the format configuration are used 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 { "errcode":0 }).
Step S309, integrating the plurality of rendering output results according to the data output sequence, and determining the integrated plurality of rendering output results as the target text information with the target data format.
At this time, the target text information may be { "ERRCode":0, "value": "charles" }. It can be seen that the rendering terminal may integrate a plurality of rendering output results according to the data output sequence, so as 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" } and default= { "error": -1 }), if the rendering terminal crashes, the rendering terminal cannot render and output the target text information required by the client terminal, and the rendering failure is caused. Therefore, the rendering terminal returns the character string { "ERRCode": -1} as spam data to the client terminal, so that the client terminal knows that the rendering terminal target cannot execute 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 that a rendering function in the rendering terminal is called (i.e., the rendering function may be a doRender function, and in practical application, it may be a rendering function that is recursively called itself, i.e., when the value of the target key field in the configuration template is a json object, the rendering function needs to be recursively called multiple times. The rendering function, when invoked, may traverse all elements in the configuration template, it being understood that elements in the configuration template may be understood as values of target key fields in the configuration template, which may be a fixed rendering path, and that in the configuration template, each template key field is made up of the target key field and fields in the rendering path (i.e., original key fields). Therefore, the rendering terminal may take a plurality of template key fields in the configuration template as second fields to be rendered, and in original text information, traverse and find the original key fields contained in the second fields to be rendered, so as to take the key values corresponding to the found 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 take the target key fields and the target values after format configuration as rendering output results corresponding to the second fields to be rendered. For easy understanding, the rendering terminal refers to the plurality of template key fields in the configuration template as the second field to be rendered, and when the rendering function is called, the rendering output result corresponding to each template key field can be obtained together. And then, the rendering terminal can integrate a plurality of rendering output results according to the data output sequence, and determine the integrated rendering output results as target text information with 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 a string "ret". When the rendering terminal determines that the value corresponding to the target key field is a character string, the rendering terminal may further perform traversal searching for the original key field (i.e. in the original josn data 3b, traversal searching for the field "ret" in the original key field 301 b) included in the second field to be rendered in the original text information, so as to take 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; and then, the rendering terminal can 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 the configuration template, a corresponding rendering output result may be obtained by invoking the rendering function. Thereby, the target text information with the target data format can be obtained. It should be understood that, if the client terminal requests the rendering terminal to output data in other formats, the rendering terminal may use the request as 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 may be rendered without changing the program and restarting.
For another example, when the original text data 3b shown in fig. 9 is { "aa": { "bb": "value" }, and the configuration template 201b found by the rendering terminal is { "a": { "b": { "c": "aa: bb" }, further reference may be made to fig. 10, which is a method for recursively calling the rendering function provided by the embodiment of the present invention. As shown in fig. 10, the rendering terminal parses the configuration template 201b for the first time, determines the value of the target key field "a" in the configuration template 201b as a json object, which may be the object 10a shown in fig. 10, where the object 10a is { "b": { "c": "aa: bb" }. Since the value of the target key field "a" is a json object, the rendering terminal needs to recursively parse the json object, that is, to continue to call the rendering function to parse the object 10a for the second time, 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 parse the object 20a for the third time to determine that the value of the target key field in the object 20a is a fixed rendering path, and the rendering path is aa: bb. Next, the rendering terminal may further search for an original key field identical to a field in the rendering path (aa: bb) in the original text data 3b to extract 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), so as to obtain a result 10a as shown in fig. 10, where the result 10a may be understood as an output result to be rendered, i.e. a { "c": value "}; the rendering terminal may then further take the output result to be rendered (i.e., { "c": "value" }) as the target value of field b (i.e., perform a second assignment), to obtain the 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 take the new output result to be rendered as the target value of field a (i.e., perform a third assignment), to obtain the result 30a as shown in fig. 10, and the result 30a may be understood as target text information, i.e., { "a": { "b": "value" }. It can be seen that the rendering function will be recursively invoked multiple times during the generation of the target text information.
When the format conversion requirement information corresponding to the original text information is obtained, the embodiment of the invention can further obtain the target data format in the format conversion requirement information and obtain the original key field contained in the original text information; then, further based on the target data format and the original key field, acquiring a configuration template corresponding to the original text information; and finally, 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. In the conversion process of 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, namely, the key value corresponding to the original key field can be obtained according to the configuration template, so that the target text information with the specified data format is output. In view of this, through this configuration template can be fast with the key value transmission in the original text information to the target text information, and improve the conversion mechanism of data format, need not to carry out the data reconstruction by people promptly, thereby can improve data format's conversion efficiency.
Further, please refer to fig. 11, which is a schematic diagram illustrating a structure 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: the system comprises a first acquisition module 10, a second acquisition module 20, a template acquisition 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 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 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 acquisition 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 a format rendering type and a data output sequence corresponding to the original key field, and in a configuration library, search a configuration template to be matched, where the configuration template includes the original key field and has the first rendering type;
the first template determining unit 302 is configured to use, as a configuration template corresponding to the original text information, a configuration template to be matched that matches the data output sequence among the configuration templates to be matched.
The specific implementation process of the first template searching unit 301 and the first template determining unit 302 may refer to the description of step S202 to step S203 in the embodiment corresponding to fig. 6, and the detailed description will not be repeated here.
Optionally, the template obtaining module 30 may also include: a target field extraction unit 303, a second template search unit 304, and a second template determination 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, according to the second rendering type, for a configuration template to be matched that includes the target key field and the original key field in a configuration library in a traversal manner;
the second template determining unit 305 is configured to use, as a configuration template corresponding to the original text information, a configuration template to be matched that matches the data output sequence among the configuration templates to be matched.
The specific implementation process of the target field extracting unit 303, the second template searching unit 304 and the second template determining unit 305 may refer to the description of step S302 to step S305 in the embodiment corresponding to fig. 8, and the description will not be repeated here.
It should be understood that, when the template obtaining module 30 searches the configuration template corresponding to the original text information through the first template searching unit 301 and the first template determining unit 302, the configuration template corresponding to the original text information will not be searched through the target field extracting unit 303, and the second template searching unit 304 and the second template determining unit 305. In contrast, when the template acquisition module 30 searches for the configuration template corresponding to the original text information through the target field extraction unit 303, the second template search unit 304 and the second template determination unit 305, the configuration template corresponding to the original text information will not be searched for through the first template search unit 301 and the first template determination unit 302.
Optionally, when the template obtaining module 30 in the data processing apparatus 1 is configured to not find a 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 acquisition module 30 may include: a first pattern 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, 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 307 is configured to perform format configuration on the original key fields in the original text information, and convert the original key fields after format configuration into template key fields 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 key field of the template and the data output sequence in the target data format.
The specific implementation manners of the first mode determining unit 306, the first configuration unit 307, and the first template generating unit 308 may refer to the description of the configuration template corresponding to the original text information in the embodiment corresponding to fig. 6, and will not be further described herein.
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 is configured to, if the target data format includes a format rendering type corresponding to the target key field, take 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 the format configuration according to the second configuration mode, 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 key field of the template and the data output sequence in the target data format.
The specific implementation manners of the second manner determining unit 309, the second configuration unit 310, and the second template generating unit 311 may refer to the description of the configuration template corresponding to the original text information in the embodiment corresponding to fig. 8, and will not be further described herein.
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 with 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 determining unit 403;
the first template parsing unit 401 is configured to parse 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 plurality of template key fields as a first field to be rendered, and in the original text information, traverse and find an original key field that is the same as the first field to be rendered, obtain a key value corresponding to the found 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;
The target determining unit 403 is configured to integrate a plurality of rendering output results according to the data output order, and determine the integrated plurality of rendering output results as target text information having the target data format.
The specific implementation process of the first template parsing unit 401, the first rendering unit 402 and the target determining unit 403 may refer to the description of step S204 to step S206 in the embodiment corresponding to fig. 6, and the description will not be repeated 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 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, so as 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 is composed of the original key field and the target key field;
the rendering subunit 4052 is configured to determine the plurality of template key fields as a second field to be rendered, and in the original text information, traverse and find the original key field included in the second field to be rendered, obtain a key value corresponding to the found original key field, and use the key value as a target value corresponding to a target key field in the second field 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 a plurality of rendering output results according to the data output order, and determine the integrated plurality of rendering output results as target text information with the target data format.
The specific implementation process of the field obtaining subunit 4051, the rendering subunit 4052, the result outputting subunit 4053 and the result integrating subunit 4054 may be referred to the description of step S306-step S309 in the embodiment corresponding to fig. 8, and will not be further described herein.
The specific implementation process of the second template parsing unit 404 and the second rendering unit 405 may refer to the description of step S305 to step S309 in the embodiment corresponding to fig. 8, and will not be further described herein.
It should be understood that when the information conversion module 40 performs rendering processing on the original text information through the first template parsing unit 401, the first rendering unit 402 and the object determining unit 403, the rendering processing will not be performed on the original text information through 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 first rendering unit 402 and the target determining unit 403 will not perform rendering processing on the original text information through the first template parsing unit 401.
The specific implementation process of the first obtaining module 10, the second obtaining module 20, the template obtaining module 30 and the information converting module 40 may be referred to the description of step S101 to step S103 in the embodiment corresponding to fig. 2, and the detailed description will not be repeated here.
When the format conversion requirement information corresponding to the original text information is obtained, the embodiment of the invention can further obtain the target data format in the format conversion requirement information and obtain the original key field contained in the original text information; then, further based on the target data format and the original key field, acquiring a configuration template corresponding to the original text information; and finally, 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. In the conversion process of 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, namely, the key value corresponding to the original key field can be obtained according to the configuration template, so that the target text information with the specified data format is output. In view of this, the invention can transmit the key value in the original text information to the target text information 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 diagram illustrating 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 above-described embodiment corresponding to fig. 1, and 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, a memory 1005, at least one communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display (Display), a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface, among others. 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 also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 12, an operating system, a network communication module, a user interface module, and a device control application program may be included in the memory 1005, which is one type of computer storage medium.
In the data processing apparatus 1000 shown in fig. 12, the network interface 1004 is mainly used to provide a network communication function; while user interface 1003 is primarily used as an interface for providing input to a user; and the processor 1001 may be used to invoke a device control application stored in the memory 1005 to implement:
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;
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, 6 or 8, and may also perform the description of the data processing apparatus 1 in the embodiment corresponding to fig. 11, which is not repeated herein. In addition, the description of the beneficial effects of the same method is omitted.
Furthermore, it should be noted here that: the embodiment of the present invention further provides a computer storage medium, in which the aforementioned computer program executed by the data processing apparatus 1 is stored, and the computer program includes program instructions, when executed by the processor, can execute the description of the data processing method in the embodiment corresponding to fig. 2, 6 or 8, and therefore, a detailed description will not be given here. In addition, the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiments of the computer storage medium according to the present invention, please refer to the description of the method embodiments of the present invention.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps 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 (Random Access Memory, RAM), or the like.
The foregoing disclosure is illustrative of the present invention and is not to be construed as limiting the scope of the invention, which is defined by the appended claims.

Claims (14)

1. A method of data processing, comprising:
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;
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;
the obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information 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;
Performing format configuration on the original key fields in the original text information, and converting the original key fields after format configuration into template key fields 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.
2. The method according to claim 1, wherein the obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to the original key field, determining the format rendering type as a first rendering type, and traversing and searching a configuration template to be matched, wherein the configuration template comprises the original key field and has the first rendering type, in a configuration library;
and taking the configuration templates to be matched, which are consistent with the data output sequence, as configuration templates corresponding to the original text information.
3. The method according to 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 the target text information having 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 plurality of 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 types;
integrating the multiple rendering output results according to the data output sequence, and determining the integrated multiple rendering output results as target text information with the target data format.
4. The method according to claim 1, wherein the obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information includes:
if the target data format comprises a format rendering type and a data output sequence corresponding to the target key field, determining the format rendering type as 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 contains the target key field and the original key field, in a configuration library according to the second rendering type;
and taking the configuration templates to be matched, which are consistent with the data output sequence, as configuration templates corresponding to the original text information.
5. The method according to 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 the 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 the 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, includes:
Acquiring a plurality of template key fields corresponding to the configuration template; each template key field is composed of the original key field and the target key field;
determining the plurality of template key fields as second to-be-rendered fields, traversing and searching the original key fields contained in the second to-be-rendered fields 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 to-be-rendered fields;
performing format configuration on the target key field and the target value based on the second 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;
integrating the multiple rendering output results according to the data output sequence, and determining the integrated multiple rendering output results as target text information with the target data format.
7. The method according to claim 1, wherein the obtaining, based on the target data format and the original key field, a configuration template corresponding to the original text information 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 a target key field in the target data format, and carrying out format configuration on the original key field 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.
8. The method of claim 1, wherein the obtaining the original key field included in the original text information 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.
9. A data processing apparatus, comprising:
The first acquisition module is used for acquiring format conversion requirement information corresponding to the original text information and acquiring a target data format in the format conversion requirement information;
the second acquisition module is used for acquiring the original key fields 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;
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 includes:
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 fields in the original text information and converting the original key fields after format configuration into template key fields according to the first configuration mode;
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.
10. The apparatus of claim 9, wherein the template acquisition module comprises:
the first template searching unit is used for determining the format rendering type as a first rendering type if the target data format comprises the format rendering type and the data output sequence corresponding to the original key field, 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;
the first template determining unit is used for 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.
11. The apparatus of claim 10, wherein the information conversion module comprises:
the first template analyzing 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;
The first rendering unit is used for determining the plurality of 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 the target determining unit is used for integrating the 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.
12. The apparatus of claim 9, wherein the template acquisition module comprises:
a target field extraction unit, 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 is used for traversing and searching the configuration templates to be matched, which contain the target key field and the original key field, in a configuration library according to the second rendering type;
And the second template determining unit is used for 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 in the configuration templates to be matched.
13. A data processing apparatus, comprising: a processor and a memory;
the processor is connected to a memory, wherein the memory is adapted to store program code, the processor being adapted to invoke the program code to perform the method according to any of claims 1-8.
14. 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 of any of claims 1-8.
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 CN110727417A (en) 2020-01-24
CN110727417B true 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)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN112379949B (en) * 2021-01-14 2021-04-13 腾讯科技(深圳)有限公司 Data processing 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

Also Published As

Publication number Publication date
CN110727417A (en) 2020-01-24

Similar Documents

Publication Publication Date Title
CN110727417B (en) Data processing method and device
JP6922538B2 (en) API learning
US11150874B2 (en) API specification generation
US9239705B2 (en) Method and apparatus for customized software development kit (SDK) generation
WO2018141140A1 (en) Method and device for semantic recognition
CN108717437B (en) Search result display method and device and storage medium
US20190050376A1 (en) Automatic value formatting based on intrinsic structural semantics
CN111274781A (en) Table display method and device, storage medium and electronic equipment
CN110968314B (en) Page generation method and device
US20150012533A1 (en) Method and client device for accessing webpage
WO2015000342A1 (en) Method and client device for accessing webpage
US9722967B2 (en) Exposing file metadata as LDAP attributes
WO2019071406A1 (en) Front-end page internationalization processing method, application server and computer readable storage medium
JP6723976B2 (en) Test execution device and program
US20200110584A1 (en) Automated code generation for functional testing of software applications
CN113268232B (en) Page skin generation method and device and computer readable storage medium
CN112114805B (en) Page generation method, device and equipment
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
CN110661693A (en) Methods, computing device-readable storage media, and computing devices facilitating media-based content sharing performed in a computing device
CN109635175B (en) Page data splicing method and device, readable storage medium and electronic equipment
CN114817794A (en) Webpage content control method, device, equipment and medium
JP2015095092A (en) Information processing system, information processing device, information processing method, and program
CN112492353B (en) Processing method, device, equipment and storage medium for data in live broadcasting room
US11977852B2 (en) Anaphoric reference resolution using natural language processing and machine learning
CN114003489B (en) Front-end code file detection 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