CN115408008A - Code text processing method, device, equipment and medium - Google Patents

Code text processing method, device, equipment and medium Download PDF

Info

Publication number
CN115408008A
CN115408008A CN202211195402.2A CN202211195402A CN115408008A CN 115408008 A CN115408008 A CN 115408008A CN 202211195402 A CN202211195402 A CN 202211195402A CN 115408008 A CN115408008 A CN 115408008A
Authority
CN
China
Prior art keywords
key
value pairs
value
value pair
code text
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.)
Pending
Application number
CN202211195402.2A
Other languages
Chinese (zh)
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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202211195402.2A priority Critical patent/CN115408008A/en
Publication of CN115408008A publication Critical patent/CN115408008A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Machine Translation (AREA)

Abstract

The disclosure provides a code text processing method, device, equipment and medium, which can be applied to the technical field of big data. The method comprises the following steps: receiving code text information from the target equipment, wherein the data format of the code text information is suitable for the target equipment; analyzing the code text information to obtain M original key value pairs, wherein the original key value pairs support operation; under the condition that the original key value pairs with the types of objects exist in the M original key value pairs, analyzing the attributes in the objects into new key value pairs to obtain N first key value pairs; calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, wherein the values of the second key-value pairs comprise the result of the operation; and updating the M original key value pairs by using the N second key value pairs according to the incidence relation between the first key value pairs and the original key value pairs to obtain updated code text information, wherein the data format of the updated code text information is suitable for the local equipment.

Description

Code text processing method, device, equipment and medium
Technical Field
The present disclosure relates to the field of big data technologies, and in particular, to a code text processing method, apparatus, device, medium, and program product.
Background
In the related art, js Object Notation (JSON) files do not support calculation in an expression, and developers generally calculate a result of the expression according to a dependency relationship between fields, and then perform variable replacement to complete data conversion.
However, when the dependency relationship between fields changes or the data of the fields themselves changes, developers need to recalculate expressions and complete variable replacement, which increases the repetitive work of the developers, and results in a complex data conversion process and data modification process and an increase in the manual conversion cost.
Disclosure of Invention
In view of the above, the present disclosure provides a code text processing method, apparatus, device, medium, and program product.
According to a first aspect of the present disclosure, there is provided a code text processing method including:
receiving code text information from the target equipment, wherein the data format of the code text information is suitable for the target equipment;
analyzing the code text information to obtain M original key value pairs, wherein M is more than or equal to 1, the original key value pairs support operation, and the types of the original key value pairs comprise objects;
under the condition that M original key value pairs with the types of objects exist, analyzing the attributes in the objects into new key value pairs to obtain N first key value pairs, wherein the first key value pairs comprise original key value pairs with the types of non-objects and key value pairs obtained by analysis in the objects, and N is more than or equal to 1 and more than or equal to M;
calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, wherein the values of the second key-value pairs comprise the result of the operation; and
and updating the M original key value pairs by using the N second key value pairs according to the incidence relation between the first key value pairs and the original key value pairs to obtain updated code text information, wherein the data format of the updated code text information is suitable for the local equipment.
According to an embodiment of the present disclosure, the first key-value pair and the original key-value pair both support an arithmetic operation, the type of the original key-value pair includes a type of the first key-value pair, the type of the first key-value pair includes a type of the second key-value pair, the type of the second key-value pair is a basic type, and the basic type includes a number, a character string, and a boolean value.
According to an embodiment of the disclosure, the type of the first key-value pair further includes an expression for performing an arithmetic operation, the expression including at least one of: operators, functions and variables;
calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, including:
under the condition that the type of the first key value pair is determined to be an expression, carrying out syntactic analysis on the expression to obtain a syntactic analysis result; and
and calling a preset grammar rule calculation expression according to a grammar analysis result to obtain an updated value of the first key value pair, wherein the preset grammar rule comprises a mathematical operation rule and a variable rule.
According to an embodiment of the present disclosure, the parsing results include function results, operator results, and variable results; in the case that the type of the first key-value pair is determined to be an expression, parsing the expression to obtain a parsing result, including:
in the case that the expression is detected to comprise an operator, determining that the operator result is non-null, wherein the operator comprises a comparison operator and a mathematical operator;
under the condition that the expression is detected to comprise a function identifier, determining that a function result is non-null, wherein the function identifier comprises a function name and a function format; and
and under the condition that the expression is detected to comprise the variable identification, determining that the variable result is not null, wherein the variable identification comprises the current object variable identification and the external variable identification.
According to the embodiment of the disclosure, according to the syntax analysis result, calling the preset syntax rule to calculate the expression, and obtaining the updated value of the first key-value pair, the method includes:
under the condition that the variable result is determined to be non-empty, obtaining the variable value of the target variable in the expression according to the variable rule and the variable identification; and
and under the condition that the function result and/or the operator result are determined to be not null, calling a mathematical operation rule to calculate the variable value to obtain an updated value of the first key-value pair.
According to the embodiment of the present disclosure, calling a preset syntax rule to calculate the values of the N first key-value pairs according to the types of the N first key-value pairs, and obtaining updated N second key-value pairs, including:
and under the condition that the type of the updated value or the first key-value pair is determined to be any basic type, returning the updated value or the value of the first key-value pair to obtain N updated second key-value pairs.
According to an embodiment of the present disclosure, the type of the first key-value pair comprises an array; calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, wherein the method comprises the following steps:
under the condition that the first key value pairs with the type of the array exist in the N first key value pairs, traversing a plurality of elements in the array, wherein the plurality of elements comprise expressions and/or numbers; and
and under the condition that the expressions exist in the plurality of elements, calculating the expressions to obtain updated N second key-value pairs.
According to an embodiment of the disclosure, the method further comprises:
under the condition that the mth original key value pair in the M original key value pairs comprises the front annotation symbol, stopping calculating the value of the mth original key value pair until the rear annotation symbol is detected, and recovering the calculation of the value of the mth original key value pair, wherein M is more than or equal to 1, and M is less than or equal to M; and
and the characters between the front annotation character and the rear annotation character are annotation characters used for describing the information of the mth original key-value pair, and the annotation characters are character string types and comprise numbers and characters.
According to an embodiment of the present disclosure, further comprising:
and in response to the preset operation of the user on the nth second key value pair in the N second key value pairs, displaying the annotation character corresponding to the nth second key value pair under the condition that the annotation character exists in the first key value pair corresponding to the nth second key value pair.
A second aspect of the present disclosure provides a code text processing apparatus including:
the receiving module is used for receiving the code text information from the target equipment, and the data format of the code text information is suitable for the target equipment;
the analysis module is used for analyzing the code text information to obtain M original key value pairs, wherein M is greater than or equal to 1, the original key value pairs support operation, and the types of the original key value pairs comprise objects;
the object processing module is used for analyzing the attribute in the object into a new key value pair under the condition that the original key value pair with the type of the object exists in the M original key value pairs to obtain N first key value pairs, wherein the first key value pairs comprise the original key value pair with the type of the non-object and the key value pair analyzed from the object, and N is more than or equal to 1 and is more than or equal to M;
the first updating module is used for calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, wherein the values of the second key-value pairs comprise the result of the operation; and
and the second updating module is used for updating the M original key value pairs by using the N second key value pairs according to the incidence relation between the first key value pairs and the original key value pairs to obtain updated code text information, and the data format of the updated code text information is suitable for the local equipment.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the above-described code text processing method.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the code text processing method described above.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the code text processing method described above.
After code text information with a data format suitable for target equipment is obtained, the obtained code text information is analyzed into M original key value pairs, and the M original key value pairs are subjected to layered processing according to the types of the key value pairs to obtain N first key value pairs; then, calculating the value of the first key-value pair according to the type of the first key-value pair to obtain N updated second key-value pairs; and finally, updating the original key-value pair by using the second key-value pair according to the incidence relation between the first key-value pair and the original key-value pair to obtain updated code text information. According to the method, the code text information is analyzed and operated through the process, developers do not need to operate according to fields and finish data replacement, the code text information data format can be converted through computer analysis, the labor cost is reduced, and the data conversion efficiency is improved. Meanwhile, the method can also avoid the error analysis caused by manual operation and improve the analysis accuracy.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
fig. 1 schematically illustrates an application scenario of a code text processing method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow diagram of a code text processing method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of an expression parsing method according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flow diagram of an array parsing method according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram illustrating a code text processing flow according to a specific embodiment of the present disclosure;
fig. 6 schematically shows a block diagram of a code text processing apparatus according to an embodiment of the present disclosure; and
fig. 7 schematically shows a block diagram of an electronic device adapted for a code text processing method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B, and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B, and C" would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and/or A, B, and C together, etc.).
In the technical scheme of the disclosure, the collection, storage, use, processing, transmission, provision, disclosure, application and other processing of the personal information of the related user are all in accordance with the regulations of related laws and regulations, necessary confidentiality measures are taken, and the customs of the public order is not violated.
In the technical scheme of the disclosure, before the personal information of the user is acquired or collected, the authorization or the consent of the user is acquired.
The present disclosure finds that in a data exchange scenario, JSON format files are generally adopted between multiple devices to complete data interaction. However, the current JSON data format does not support variables, expressions and functions, and needs to access a data table processed by a developer to realize data replacement in the JSON format, which lacks flexibility. And when the preset field in the JSON format file is obtained by calculating other fields, after determining a plurality of fields on which the preset field depends, a developer calculates the value of the preset field according to the determined fields, and fills the calculated value into the preset field.
Under the condition that a plurality of fields on which the preset fields depend are changed or the values of the fields are changed, the developer needs to repeat the calculation process to obtain the changed data values of the preset fields, and replace the original values in the preset fields with the updated data values. This results in a very complicated process for processing JSON-formatted files, increasing the workload of developers.
In addition, after the value of the preset field is obtained through calculation, a developer cannot determine a plurality of fields having a dependency relationship with the preset field according to a final calculation result of the preset field. Therefore, under the condition that errors exist in the calculation result, the dislocation source cannot be accurately positioned, and the modification cost is increased.
The embodiment of the disclosure provides a code text processing method, which receives code text information from a target device, wherein the target device comprises a mobile terminal or a server, and the data format of the code text information is suitable for the target device; analyzing the code text information to obtain M original key value pairs, wherein M is more than or equal to 1, the original key value pairs support operation, the operation comprises variable operation and mathematical operation, and the type of the original key value pairs comprises an object; under the condition that M original key value pairs with the types of objects exist, analyzing the attributes in the objects into new key value pairs to obtain N first key value pairs, wherein the first key value pairs comprise original key value pairs with the types of non-objects and key value pairs obtained by analysis in the objects, and incidence relations exist between the first key value pairs and the original key value pairs; n is greater than or equal to 1 and N is greater than or equal to M; calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs, wherein the values of the second key-value pairs comprise the result of the operation; and updating the M original key value pairs by using the N second key value pairs according to the incidence relation between the first key value pairs and the original key value pairs to obtain updated code text information, wherein the data format of the updated code text information is suitable for local equipment.
Fig. 1 schematically shows an application scenario of a code text processing method according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario 100 according to this embodiment may include a target device 110, a local device 120, and a network 130. The target device 110 includes a first target device 111 and/or a second target device 112, and the local device 120 includes a first local device 121 and/or a second local device 122.
The network 130 serves as a medium for providing a communication link between the target device 110 and the local device 120. For example, the network may provide a medium for communication links between the first target device 111 and the first local device 121, between the first target device 111 and the second local device 122, between the second target device 112 and the first local device 121, or between the second target device 112 and the second local device 122. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The first target device 111 and the first local device 121 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. The second target device 112 and the second local device 122 may be servers for providing various services.
For example, the second target device 112 provides a back-office management server (by way of example only) that supports a website browsed by the user using the first local device 111. The second local device 122 provides a background management server supporting the website browsed by the user using the first target device 121. The background management server can analyze and process the received data such as the user request and the like, and feed back a processing result.
It should be noted that the code text processing method provided by the embodiment of the present disclosure may be executed by the target device 110 or the local device 120. Specifically, the processing may be performed by the first target device 111 or the second target device 112 included in the target device 110, and the first local device 121 or the second local device 122 in the local device 120. Accordingly, the code text processing apparatus provided by the embodiment of the present disclosure may be generally disposed in the target device 110 or the local device 120.
The code text processing method provided by the embodiment of the present disclosure may also be performed by a server cluster different from the second target device 112 and the second local device 122. Accordingly, the code text processing apparatus provided by the embodiment of the present disclosure may also be disposed in a server cluster different from the second target device 112 and the second local device 122.
It should be understood that the target device, the type of devices included in the local device, the number of devices included in the local device, and the network in fig. 1 are merely illustrative. There may be any number and any type of target devices, local devices, and networks, as desired for an implementation.
The code text processing method of the disclosed embodiment will be described in detail below with fig. 2 to 5 based on the scenario described in fig. 1.
Fig. 2 schematically shows a flow chart of a code text processing method according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S210 to S250.
In operation S210, code text information is received from a target device, and a data format of the code text information is suitable for the target device.
According to an embodiment of the present disclosure, the code text information is used for transmission between the target device and the local device. After receiving the code text information to be analyzed from the target equipment, analyzing the code text information by using an analyzer deployed on the local equipment, and completing conversion of data in the code text information. The code text information to be analyzed can support the operation, and the updated code text information obtained based on the analyzer does not support the operation.
For example, the code text information in the target device is in an extended format of JSON format, referred to as JSONx format. The JSONx format is added with variables, functions and expressions on the basis of the JSON format and is used for supporting operation operations including variable operation and data operation.
According to the embodiment of the disclosure, the target device may be a mobile terminal or a server with data transmission and data analysis functions, and a parser for parsing code text information is configured in the target device.
In operation S220, the code text information is parsed to obtain M original key-value pairs.
According to an embodiment of the present disclosure, the code text information may be a file in xml format or txt format. After receiving the code text information from the target device, analyzing the fields and the field parameters in the code text information into corresponding original key value pairs to obtain M original key value pairs, wherein M is greater than or equal to 1.
Wherein the type of the original key-value pair includes at least one of: objects, arrays, expressions, numbers, strings, boolean values, and null values. Also, based on the various types, the original key-value pairs may support various operational operations, including variable operations and mathematical budgets.
It should be noted that, in the process of analyzing the code text information, multiple lines of codes inside the code text information may be used as one object to be analyzed, so as to obtain multiple original key value pairs.
For example, as an example of code text information, { "id":100000000000000L, "name": three in tension "," age ":39} is parsed to obtain 3 original key-value pairs, id =100000000000000l, name = three in tension, and age =39. The name of a main key of the first original key value pair is 'id', the key value is '100000000000000L', and the type is a number + character string; the name of the primary key of the second original key-value pair is 'name', the key value is 'Zhang III', and the type is a character string; the primary key name of the third original key-value pair is "age", the key value is "39", and the type is a number.
According to the embodiment of the disclosure, the code text information may include a plurality of instances, and after the plurality of instances are analyzed, M original key-value pairs are obtained.
In operation S230, when it is determined that there is an original key value pair with a type of an object in the M original key value pairs, an attribute in the object is analyzed as a new key value pair to obtain N first key value pairs, where the first key value pair includes the original key value pair with a type of a non-object and a key value pair obtained by analysis from the inside of the object.
According to the embodiment of the disclosure, for the original key value pair of which the type is the object, the analyzer cannot directly calculate, and the attribute in the object needs to be analyzed in the next step. Under the condition that the M original key value pairs have the original key value pairs with the types of the objects, analyzing a plurality of data included in the objects into new key value pairs under the objects until the original key value pairs do not have the key value pairs with the types of the objects, and finishing the processing of the original key value pairs.
According to an embodiment of the present disclosure, the process of obtaining N first key-value pairs includes: and traversing the M original key value pairs, and analyzing the attribute information in the original key value pair into a new key value pair under the condition that the original key value pair with the type as the object is detected. After the original key-value pair is processed, the type of the next original key-value pair is detected, and N first key-value pairs are obtained after traversing and analyzing M original key-value pairs are completed, wherein N is more than or equal to 1 and N is more than or equal to M.
According to the embodiment of the disclosure, after the object is analyzed to obtain a new key-value pair, all the key-value pairs obtained by analysis in the object are traversed. And under the condition that the type of the new key value pair still comprises the object, continuously analyzing the new key value pair with the type as the object, and ensuring that the types of N first key value pairs obtained by analyzing the M original key value pairs are all non-objects.
Because the first key value pair is obtained by directly obtaining or analyzing the original key value pair, an incidence relation exists between the first key value pair and the original key value pair. Specifically, the association relationship may be determined by the primary key of the first key-value pair and the original key-value pair.
For example, one example included in the code text information is:
{"a":1,"b":"2","c":{"d":3,"e":4}}
wherein, 3 original key value pairs are obtained by analysis, wherein the key value pairs are respectively a =1, b = '2', c = {'d': 3, 'e': 4}, the key value of the first original key value pair is 1, and the type is a number; the key value of the second original key value pair is '2', and the type is a character string; the key value of the third original key-value pair is { "d":3, "e":4}, the type is an object, and the third key-value pair comprises two attributes of d and e. And analyzing the third original key-value pair to obtain two first key-value pairs d =3 and e =4, wherein the types are numbers. Since the types of the first original key-value pair and the second original key-value pair are both non-objects, a total of 4 first key-value pairs are obtained.
In operation S240, values of the N first key-value pairs are calculated according to the types of the N first key-value pairs, so as to obtain updated N second key-value pairs.
According to an embodiment of the present disclosure, the types of the M original key-value pairs include an object, and none of the types of the N first key-value pairs obtained by the parsing includes an object. After N first key value pairs are obtained through analysis, the type of the first key value pairs is judged, a corresponding operation method is determined according to the type of the first key value pairs, the N first key values are calculated, and an operation result is obtained. And updating the key values of the N first key-value pairs by using the calculated operation result, wherein the updated first key-value pair is called a second key-value pair because the key values of the first key-value pair are changed.
Specifically, for the first key-value pair whose type is an expression, an operation method or an operation function may be called, and the result of the expression may be calculated to obtain an updated second key-value pair.
In operation S250, according to the association relationship between the first key-value pair and the original key-value pair, the M original key-value pairs are updated by using the N second key-value pairs, so as to obtain updated code text information.
According to the embodiment of the disclosure, the first key-value pair is calculated, and the second key-value pair is obtained after updating, but the primary key names of the first key-value pair and the second key-value pair are not changed, and only the key value is changed. Accordingly, the association between the first key-value pair and the original key-value pair may also be mapped as an association between the second key-value pair and the original key-value pair.
The type of the original key-value pair includes an object and the type of the first key-value pair does not include an object. And after the second key value pair is obtained, updating the original key value pair with the type as the object by using the second key value pair according to the incidence relation between the mapped second key value pair and the original key value pair to obtain the updated code text information. The data format of the updated code text information is suitable for the local device.
According to the embodiment of the disclosure, in the process of analyzing the code text information by using the analyzer of the target device, the code text information supporting the operation is converted into the updated code text information not supporting the operation. The updated code text information is suitable for application scenes which adopt JSON format files as data exchange files.
For example, for software A being developed, a front-end developer is used to develop the front-end interface of software A, and a back-end developer is used to develop the back-end kernel execution code of software A. The front end and the back end realize data interaction through an interface. In the development process, a back-end developer uses data storage configuration information in a JSONx format, and a front-end developer uses data storage configuration information in a general JSON format. The front-end developer cannot analyze all the configuration information after acquiring the configuration information transmitted by the back-end developer. At this time, the device used by the front-end developer is a local device, and the device used by the back-end developer is a target device. The front-end developer can analyze the configuration file transmitted by the back end by installing the analyzer.
In addition, when data transmission is performed between a terminal device and the terminal device, between a server and a server, between a terminal device and a server, or between a server cluster and a server cluster, the above devices may be used as a target device and a local device in the present disclosure to perform data interaction.
For another example, the obtained code text information may be stored directly to the local device after the data transfer is completed. And responding to the call request of the local equipment, and analyzing the code text information. And displaying the updated code text information in response to a display request of the local equipment. Because the obtained code text information comprises the expression, after the code text information is analyzed, the dependency relationship shown by the expression can still be obtained according to the updated code text information.
In addition, the method for directly storing the obtained code text information to the local device may be wireless transmission, and may also be transmission through a mobile storage medium, for example, a usb disk, a mobile hard disk, and the like.
After code text information with a data format suitable for target equipment is obtained, the obtained code text information is analyzed into M original key value pairs, and the M original key value pairs are subjected to layered processing according to the types of the key value pairs to obtain N first key value pairs; then, calculating the value of the first key-value pair according to the type of the first key-value pair to obtain N updated second key-value pairs; and finally, updating the original key value pair by using the second key value pair according to the incidence relation between the first key value pair and the original key value pair to obtain updated code text information. According to the method and the device, the code text information is analyzed and operated through the processes, the conversion of the data format of the code text information is realized, developers do not need to operate according to fields and complete data replacement, the labor cost is reduced, and the data conversion efficiency is improved. Meanwhile, the method can avoid the error analysis caused by manual operation and improve the analysis accuracy.
In addition, the code text information of the target device is processed through the code file processing method disclosed by the invention, and the obtained updated code text information can be suitable for a universal JSON data format, so that the method provided by the invention can realize the extension of the JSON data format, is beneficial to increasing the flexibility and the applicability of the JSON data format, and enables the JSON data format to be suitable for wider application scenes.
According to an embodiment of the present disclosure, the first key-value pair and the original key-value pair both support an arithmetic operation, the type of the original key-value pair includes a type of the first key-value pair, the type of the first key-value pair includes a type of the second key-value pair, the type of the second key-value pair is a basic type, and the basic type includes a number, a character string, and a boolean value.
According to the embodiment of the present disclosure, the type of the original key-value pair includes an object, and the first key-value pair is obtained by parsing the original key-value pair whose type is the object, so that the type of the first key-value pair does not include the object. The second key-value pair is obtained by operating the first key-value pair with the type being a non-basic type, and the type of the second key-value pair only comprises a basic type.
The base type is a base type of the JSON data format, such as numbers, character strings, and boolean values, including false and true. Wherein the base type further includes null.
FIG. 3 schematically illustrates a flow diagram of an expression parsing method according to an embodiment of the disclosure.
As shown in fig. 3, the expression parsing method of this embodiment includes operations S341 to S342, which may be a specific embodiment of operation S240.
According to an embodiment of the disclosure, the type of the first key-value pair further includes an expression for performing an arithmetic operation, the expression including at least one of: operators, functions, and variables. Furthermore, the expression may also include character strings, numbers.
The function is composed of a function name (letter + number and/or character string starting with letter), a left bracket, a parameter and a right bracket. For example, strstr (param 1, param 2), strstr represents a function name, and param1 and param2 represent parameters.
The variables include a current object variable and an external variable, the external variable is composed of an alphabetical beginning letter + number and/or character string, $ represents the current object, and $ parent represents the parent object of the current object. For example, $.
In operation S341, in the case where it is determined that the type of the first key-value pair is an expression, the expression is parsed, resulting in a parsing result.
According to the embodiment of the disclosure, the type of the first key-value pair is an expression, the key value representing the first key-value pair may be changed according to information of a variable or according to different requirements of a user, and the key value of the first key-value pair is not a final result.
When the type of the first key-value pair is determined to be an expression, the expression is analyzed in a syntax mode, and the composition of the expression is determined. Specifically, whether the expression includes an operator, a variable, and a function or a combination of the operator, the variable, and the function is determined, and a syntax analysis result is obtained.
According to an embodiment of the present disclosure, the parsing result includes a function result, an operator result, and a variable result. As a specific embodiment, the method of determining a result of parsing includes:
in the event that it is detected that the expression includes an operator, the operator result is determined to be non-null, the operator including a comparison operator and a mathematical operator. Specifically, the compare operators include >, <, =, > =, <=, and! =, for comparing number and string size. The mathematical operators comprise addition and subtraction operators for addition and subtraction of numerical types; the device also comprises a multiplication and division operator used for multiplication and division of the digital type; the system also comprises a remainder operator used for modulus taking of the number type; and the bracket operator is also included for controlling the execution sequence of the operators in the expression.
And in the case that the expression is detected to comprise the function identifier, determining that the function result is not null, wherein the function identifier comprises a function name and a function format. Specifically, the function name includes a common function name and a custom function name. The common function name comprises a common function in the local device, such as a splicing function concat, and the custom function name comprises a script function which is customized by a user according to requirements. The function format is left and right brackets behind the function name.
And under the condition that the expression is detected to comprise the variable identification, determining that the variable result is non-null, wherein the variable identification comprises the current object variable identification and the external variable identification.
For example, the expression includes a comparison relationship that may be ($. A +3 × 2) >5, representing the sum of the current object variable a and the products of numbers 3 and 2, and number 5. The function result in the grammar analysis result of the current expression is null, the operator result is non-null and comprises a mathematical operator and a comparison operator, and the variable result is non-null and comprises a current variable.
The expression may also be concat ($. B, "abc") which means that the current variable b is concatenated with the string "abc". The result of the function in the parsing result is non-null, the function identifier may be "concat", the result of the variable is non-null, and the result of the operator is null.
In operation S342, a preset grammar rule is invoked to calculate an expression according to the parsing result, so as to obtain an updated value of the first key-value pair, where the preset grammar rule includes a mathematical operation rule and a variable rule.
According to the embodiment of the disclosure, after the expression is parsed to obtain a parsing result, a preset grammar rule corresponding to the parsing result is called to calculate the expression. The preset grammar rule includes a mathematical operation rule including an operation order of a plurality of operators and a variable rule including a method of calling a variable and an execution method of the variable itself, for example.
After the expression is calculated by using the preset grammar rule, the key value of the first key value pair is updated to obtain the updated value of the first key value pair, and the updated value corresponds to the expression.
As a specific embodiment, the method for calculating the expression includes: under the condition that the variable result is determined to be non-empty, obtaining a variable value of a target variable in the expression according to the variable rule and the variable identification; and under the condition that the function result and/or the operator result are determined to be not null, calling a mathematical operation rule to calculate the variable value to obtain an updated value of the first key-value pair.
Specifically, after the expression is parsed, the parsing result is obtained, including an operator result, a function result, and a variable result. And under the condition that the operator result, the function result and the variable result are determined not to be empty, calculating the expression according to the identification information included in the operator result, the function result and the variable result.
For example, taking the first key-value pair idNameAndage = concat ($. Id, $. Name, $. Age), the key value of the first key-value pair is an expression, the function result and the variable result are both non-null, and the operator result is null. And the variable identification is $, id, which means that the current expression only includes the current object variable id, and the variable rule of the current object variable id is the field value under the calling id field. Similarly, the field values under the name and age fields are called, respectively. And the function result is non-null, and the function identifier is detected to be concat, and the field values of the id, the name and the age are spliced according to a concat method in the mathematical operation rule to obtain an updated value of the first key value pair. According to the original key value pair id =100000000000000l, name = zhangsan, and age =39, the finally obtained update value is "100000000000000 zhangsan 39".
As another example, for a specific embodiment in the code text information, { "name": tension three "," child ": name": lie four "," desc ": can" }. The original key-value pair includes name = zhangsan and child = { "name": "lie four", "desc": can ($ parent. Name) ") }. The first key-value pair obtained by parsing the original key-value pair includes name = zhang, name = lie, desc = canat ($ parent. The type of the first key value pair desc = canat ("son of" $ parent.name ") is an expression, the expression includes a function canat and an external variable $ parent, and the calculated second key value pair is the son of desc = zhang.
The method and the device have the advantages that the operator, the function and the variable in the expression are called, the preset grammar rule is called to support the expression operation in the JSON format, the automatic operation of the value in the JSON format is realized, developers are not required to complete the expression operation, the workload of the developers is reduced, and the data conversion efficiency is improved.
In addition, under the format, the dependency relationship among the fields can be intuitively determined according to the operation result of the expression, so that developers can understand the dependency relationship, the communication time is reduced, and the developers do not need to call the annotation document again to determine the dependency relationship among the fields.
According to an embodiment of the present disclosure, in a case where it is determined that the type of the update value or the first key-value pair is any one of the basic types, the update value or the value of the first key-value pair is returned, so as to obtain N updated second key-value pairs.
Because the JSON data format supports key value pairs of basic types including numbers, character strings, boolean values and the like, and the key value pairs of the basic types do not need to be subjected to data analysis and conversion, the first key value pair of the basic types is not processed in the process of data conversion, and the value of the first key value pair of the basic types is directly returned. Similarly, for the updated value after the expression is calculated, in the case where the updated value is determined to be any one of a number, a character string, a boolean value, null, and the like, the updated value is returned and the second key-value pair is obtained.
According to an embodiment of the present disclosure, in the case where the type of the first key-value pair is any one of the base types, the current value is returned without calculating the first key-value pair. Similarly, where the type of the first key-value pair is a combination of multiple base types, the current value of the first key-value pair is also returned. For example, for a first key-value pair id =100000000000000L, the type is a number + string, while the second key-value pair returned is still id =100000000000000L.
FIG. 4 schematically shows a flow diagram of an array parsing method according to an embodiment of the disclosure.
As shown in fig. 4, the array parsing method of this embodiment includes operations S410 to S420, which are set before operations S341 to S342.
According to an embodiment of the disclosure, the type of the first key-value pair comprises an array. The array is made up of a set of values enclosed in brackets, e.g., [1,2, "3, {" a ":4} ], including numbers 1 and 2, string 3, and object {" a ":4}.
In operation S410, in the case where it is determined that there is a first key-value pair of the type array among the N first key-value pairs, a plurality of elements within the array are traversed.
According to embodiments of the present disclosure, a plurality of elements within an array include expressions and/or numbers. After the original key-value pairs with the types of the objects are analyzed into N first key-value pairs, further traversing the N first key-value pairs to determine whether the first key-value pairs with the types of the arrays exist. In the case where there is a first key-value pair of type array, the plurality of elements in the array are traversed, similar to processing the original key-value pair of type object, to determine whether there is still an array in the plurality of elements.
In operation S420, in the case that it is determined that an expression exists in the plurality of elements, the expression is calculated, resulting in updated N second key-value pairs.
According to the embodiment of the present disclosure, in a case where it is determined that an expression exists in a plurality of elements, parsing the expression is performed to obtain a parsing result, similar to operations S341 to S342; and calling a preset grammar rule to calculate an expression according to the grammar analysis result to obtain an updated value of the first key-value pair.
And under the condition that a plurality of expressions exist in a plurality of elements or a plurality of expressions exist under a certain element, all the expressions are calculated in a traversing way to obtain N updated second key-value pairs.
According to the embodiment of the disclosure, under the condition that the mth original key value pair of the M original key value pairs comprises the front annotation symbol, stopping the calculation of the value of the mth original key value pair until the rear annotation symbol is detected, and recovering the calculation of the value of the mth original key value pair, wherein M is greater than or equal to 1, and M is less than or equal to M; and
and the characters between the front annotation character and the rear annotation character are annotation characters used for describing the information of the mth original key-value pair, and the annotation characters are character string types and comprise numbers and characters. The front note may be "/", and the back note may be "/".
For example, one example of coded text information is { "a":1, "b":2, "c": $. A + $. B/. C is the sum of a and b =/}, and the 3 rd original key value pair c = $. A + $. B/. C is the sum of a and b/. The key includes an annotation character. In the process of calculating the expression of the key value pair, when the pre-comment symbol is detected, the acquisition of the code or variable information behind the pre-comment symbol is stopped until the post-comment symbol is detected, and the calculation of the expression is resumed.
According to the embodiment of the disclosure, in response to the preset operation of the user on the nth second key value pair in the N second key value pairs, the annotation character corresponding to the nth second key value pair is displayed under the condition that the annotation character is determined to exist in the first key value pair corresponding to the nth second key value pair.
According to the embodiment of the disclosure, after the parser finishes parsing the code text information and obtains the updated second key-value pair, the user can click the second key-value pair to display the annotation character under the second key-value pair.
According to the embodiment of the disclosure, the JSON data format does not support the annotation, when the file in the JSON data format is analyzed, an error is reported when the annotation symbol is detected, and the analysis of the code behind the annotation is stopped. In the related art, developers generally annotate files to be parsed by creating annotation documents. When a file receiver reads a file, the annotation document needs to be called or the code document needs to be communicated with a developer to understand the code file, the reading experience of the file receiver is influenced, the file receiver also costs extra storage space to store the annotation document, and unnecessary file calling processes are increased.
According to the method and the device, the code text information is analyzed, the annotation in the code text information is supported, a reader does not need to call an annotation file, the file receiver can be supported to know the internal annotation information of the code text information, the file storage space of a computer is released, and the reading experience of the file receiver is improved.
According to the embodiment of the disclosure, the detection of the annotation character can be completed in the process of analyzing the code text information. At this time, the pair of primary key values does not include the comment character, the front comment symbol and the rear comment symbol.
Fig. 5 schematically shows a code text processing flow diagram according to a specific embodiment of the present disclosure.
As shown in fig. 5, the code text processing flow includes operations S501 to S508.
In operation S501, start. Specifically, the local device receives the code text information from the target device, and analyzes the code text information to obtain M original key value pairs.
In operation S502, it is determined whether a key value of a current key-value pair is an object. Specifically, after M original key-value pairs are obtained in operation S501, the M original key-value pairs are traversed to determine whether there is an original key-value pair of which the type is an object. In the process of traversal, it is determined whether the type of the current original key-value pair is an object, that is, whether the key value of the current original key-value pair is an object.
If it is determined that the type of the current original key-value pair is an object, operation S503 is performed to resolve the attribute in the object into a new key-value pair. Operation S504 is then entered to traverse all key-value pairs within the object. In the process of traversing all key-value pairs in the object, returning to operation S502, it is determined whether the type of the current key-value pair is an object. And after traversing all the original key-value pairs, obtaining N first key-value pairs.
In the case that the type of the current original key-value pair is determined to be a non-object, operation S505 is entered to determine whether the key-value of the current key-value pair is a basic type. Specifically, the current key-value pair is the first key-value pair at this time.
If it is determined that the key value of the current key value pair is not the basic type, the operation S506 is performed, syntax analysis is performed on the expression, and the expression is calculated to obtain an updated value of the key value pair. Specifically, under the condition that the key value of the current key value pair is determined to be the expression, the calculation of the expression is completed through operation S506; in the case that the key value of the current key value pair is an array, a plurality of elements in the array are traversed, and operation S506 is performed to calculate the expression in the array.
After completing operation S505 and determining the key value of the current key-value pair as the basic type, or completing the calculation of the expression of operation S506, operation S507 is entered to determine whether the traversal is completed. Specifically, whether the array or the object where the current key value pair is located is traversed or not is determined.
In case it is determined that the traversal is not completed, returning to operation S502, the traversal of the next key value pair or the next element or the next object is continued. In the case where it is determined that the traversal has been completed, the operation S508 is entered and ended. Specifically, the M original key-value pairs are updated by using the obtained N second key-value pairs, and updated code text information is obtained.
Fig. 6 schematically shows a block diagram of a code text processing apparatus according to an embodiment of the present disclosure.
As shown in fig. 6, the code text processing apparatus 600 of this embodiment includes a receiving module 610, a parsing module 620, an object processing module 630, a first updating module 640, and a second updating module 650.
The receiving module 610 is configured to receive code text information from the target device, where a data format of the code text information is suitable for the target device. In an embodiment, the receiving module 610 may be configured to perform the operation S210 described above, which is not described herein again.
And the analyzing module 620 is configured to analyze the code text information to obtain M original key-value pairs, where M is greater than or equal to 1, the original key-value pairs support operation, and the type of the original key-value pairs includes an object. In an embodiment, the parsing module 620 may be configured to perform the operation S220 described above, which is not described herein again.
The object processing module 630 is configured to, when it is determined that there are M original key value pairs with a type of an object in the original key value pairs, parse an attribute in the object into new key value pairs to obtain N first key value pairs, where the first key value pairs include original key value pairs with a type of a non-object and key value pairs parsed from the inside of the object, and N is greater than or equal to 1 and is greater than or equal to M. In an embodiment, the object processing module 630 may be configured to perform the operation S230 described above, which is not described herein again.
The first updating module 640 is configured to calculate values of the N first key-value pairs according to types of the N first key-value pairs to obtain updated N second key-value pairs, where the values of the second key-value pairs include results of the operation. In an embodiment, the first updating module 640 may be configured to perform the operation S240 described above, and is not described herein again.
And a second updating module 650, configured to update the M original key-value pairs with the N second key-value pairs according to the association relationship between the first key-value pair and the original key-value pair, so as to obtain updated code text information, where a data format of the updated code text information is applicable to the local device. In an embodiment, the second updating module 650 may be configured to perform the operation S250 described above, and is not described herein again.
According to an embodiment of the present disclosure, the first update module 640 includes a first determination unit and a second determination unit.
The first determining unit is used for performing syntactic analysis on the expression under the condition that the type of the first key-value pair is determined to be the expression, and obtaining a syntactic analysis result. In an embodiment, the first determining unit may be configured to perform operation S341 described above, which is not described herein again.
The second determining unit is used for calling a preset grammar rule calculation expression according to the grammar analysis result to obtain an updated value of the first key value pair, and the preset grammar rule comprises a mathematical operation rule and a variable rule. In an embodiment, the second determining unit may be configured to perform the operation S342 described above, which is not described herein again.
According to an embodiment of the present disclosure, the first determination unit includes a first determination subunit, a second determination subunit, and a third determination subunit.
The first determining sub-unit is configured to determine that an operator result is non-null if it is detected that the expression includes an operator, the operator including a comparison operator and a mathematical operator.
The second determining subunit is configured to determine that the function result is non-null if it is detected that the expression includes a function identifier, where the function identifier includes a function name and a function format.
The third determining subunit is configured to determine that the variable result is non-null when it is detected that the expression includes a variable identifier, where the variable identifier includes a current object variable identifier and an external variable identifier.
According to an embodiment of the present disclosure, the second determination unit includes a fourth determination subunit and a fifth determination subunit.
And the fourth determining subunit is used for acquiring the variable value of the target variable in the expression according to the variable rule and the variable identifier under the condition that the variable result is determined to be non-empty.
And the fifth determining subunit is used for calling a mathematical operation rule to calculate the variable value to obtain an updated value of the first key-value pair under the condition that the function result and/or the operator result are determined to be not null.
According to an embodiment of the present disclosure, the first updating module 640 further includes a third determining unit, configured to, when it is determined that the update value or the type of the first key-value pair is any one of the basic types, return the update value or the value of the first key-value pair to obtain N updated second key-value pairs.
According to an embodiment of the present disclosure, the first updating module 640 further includes a fourth determining unit and a fifth determining unit.
The fourth determining unit is used for traversing a plurality of elements in the array under the condition that the first key value pair with the type of the array exists in the N first key value pairs, wherein the plurality of elements comprise expressions and/or numbers. In an embodiment, the fourth determining unit may be configured to perform the operation S410 described above, which is not described herein again.
And the fifth determining unit is used for calculating the expression under the condition that the expression exists in the plurality of elements, so as to obtain the updated N second key-value pairs. In an embodiment, the fifth determining unit may be configured to perform the operation S420 described above, which is not described herein again.
According to an embodiment of the present disclosure, the code text processing apparatus 600 further includes an annotation module, configured to, when detecting that the mth original key-value pair of the M original key-value pairs includes the previous annotation, stop the calculation of the value of the mth original key-value pair until the subsequent annotation is detected, resume the calculation of the value of the mth original key-value pair, where M is greater than or equal to 1, and M is less than or equal to M; and wherein the character between the pre-annotation character and the post-annotation character is an annotation character for describing information of the mth original key-value pair, and the annotation character is of a character string type including numbers and words.
According to an embodiment of the present disclosure, the code text processing apparatus 600 further includes a displaying module, configured to, in response to a preset operation of a user on an nth second key-value pair of the N second key-value pairs, display an annotation character corresponding to the nth second key-value pair in a case where it is determined that the annotation character exists for the first key-value pair corresponding to the nth second key-value pair.
Fig. 7 schematically shows a block diagram of an electronic device adapted for a code text processing method according to an embodiment of the present disclosure.
As shown in fig. 7, an electronic device 700 according to an embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. The processor 701 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 701 may also include on-board memory for caching purposes. The processor 701 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM703, various programs and data necessary for the operation of the electronic apparatus 700 are stored. The processor 701, the ROM 702, and the RAM703 are connected to each other by a bus 704. The processor 701 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 702 and/or the RAM 703. Note that the programs may also be stored in one or more memories other than the ROM 702 and the RAM 703. The processor 701 may also perform various operations of method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 700 may also include input/output (I/O) interface 705, which input/output (I/O) interface 705 is also connected to bus 704, according to an embodiment of the present disclosure. The electronic device 700 may also include one or more of the following components connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that the computer program read out therefrom is mounted in the storage section 708 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 702 and/or the RAM703 and/or one or more memories other than the ROM 702 and the RAM703 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated by the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the code text processing method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 701. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, and the like. In another embodiment, the computer program may also be transmitted in the form of a signal over a network medium, distributed, and downloaded and installed via the communication section 709, and/or installed from the removable medium 711. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program, when executed by the processor 701, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The above-described embodiments, objects, technical solutions and advantages of the present disclosure are further described in detail, it should be understood that the above-described embodiments are only examples of the present disclosure, and should not be construed as limiting the present disclosure, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present disclosure should be included in the protection scope of the present disclosure.

Claims (13)

1. A code text processing method, comprising:
receiving code text information from a target device, wherein the data format of the code text information is suitable for the target device;
analyzing the code text information to obtain M original key value pairs, wherein M is more than or equal to 1, the original key value pairs support operation, and the types of the original key value pairs comprise objects;
under the condition that M original key value pairs with the types of objects exist, analyzing the attributes in the objects into new key value pairs to obtain N first key value pairs, wherein the first key value pairs comprise original key value pairs with the types of non-objects and key value pairs obtained by analyzing in the objects, and N is greater than or equal to 1 and is greater than or equal to M;
calculating the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain N updated second key-value pairs, wherein the values of the second key-value pairs comprise the result of the operation; and
and updating M original key-value pairs by using the N second key-value pairs according to the incidence relation between the first key-value pairs and the original key-value pairs to obtain updated code text information, wherein the data format of the updated code text information is suitable for local equipment.
2. The method of claim 1, wherein the first key-value pair and the original key-value pair each support the arithmetic operation, the type of the original key-value pair comprising a type of the first key-value pair, the type of the first key-value pair comprising a type of the second key-value pair, the type of the second key-value pair being a base type, the base type comprising a number, a character string, and a boolean value.
3. The method of claim 2, wherein the type of the first key-value pair further comprises an expression for performing the arithmetic operation, the expression comprising at least one of: operators, functions and variables;
the calculating values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs includes:
under the condition that the type of the first key value pair is determined to be an expression, carrying out syntactic analysis on the expression to obtain a syntactic analysis result; and
and calling a preset grammar rule to calculate the expression according to the grammar analysis result to obtain an updated value of the first key value pair, wherein the preset grammar rule comprises a mathematical operation rule and a variable rule.
4. The method of claim 3, wherein the parsing results include function results, operator results, and variable results; the parsing the expression to obtain a parsing result when determining that the type of the first key-value pair is the expression includes:
in an instance in which it is detected that the expression includes an operator, determining that the operator result is non-null, the operator including a comparison operator and a mathematical operator;
under the condition that the expression is detected to comprise a function identifier, determining that the function result is non-null, wherein the function identifier comprises a function name and a function format; and
and under the condition that the expression is detected to comprise variable identifications, determining that the variable result is not null, wherein the variable identifications comprise current object variable identifications and external variable identifications.
5. The method of claim 4, wherein said invoking a predetermined grammar rule to compute the expression according to the parsing result to obtain an updated value of the first key-value pair comprises:
under the condition that the variable result is determined to be not empty, obtaining a variable value of a target variable in the expression according to the variable rule and the variable identification; and
and under the condition that the function result and/or the operator result are determined to be non-null, calling the mathematical operation rule to calculate the variable value to obtain an updated value of the first key-value pair.
6. The method of claim 3, wherein the invoking a preset syntax rule to calculate the values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs comprises:
and under the condition that the updating value or the type of the first key-value pair is determined to be any basic type, returning the updating value or the value of the first key-value pair to obtain N updated second key-value pairs.
7. The method of claim 1, wherein the type of the first key-value pair comprises an array; the calculating values of the N first key-value pairs according to the types of the N first key-value pairs to obtain updated N second key-value pairs includes:
under the condition that the first key value pairs with the type of an array exist in the N first key value pairs, traversing a plurality of elements in the array, wherein the plurality of elements comprise expressions and/or numbers; and
and under the condition that the expression exists in the plurality of elements, calculating the expression to obtain N updated second key-value pairs.
8. The method of claim 1, further comprising:
under the condition that the mth original key value pair in M original key value pairs comprises a front annotation symbol, stopping calculating the value of the mth original key value pair until a rear annotation symbol is detected, and recovering the calculation of the value of the mth original key value pair, wherein M is more than or equal to 1, and M is less than or equal to M; and
and the characters between the front annotation character and the rear annotation character are annotation characters used for describing the information of the mth original key-value pair, and the annotation characters are character string types and comprise numbers and characters.
9. The method of claim 8, further comprising:
responding to preset operation of a user on an nth second key value pair in N second key value pairs, and displaying an annotation character corresponding to the nth second key value pair under the condition that the first key value pair corresponding to the nth second key value pair has the annotation character.
10. A code text processing apparatus comprising:
the receiving module is used for receiving code text information from target equipment, and the data format of the code text information is suitable for the target equipment;
the analysis module is used for analyzing the code text information to obtain M original key value pairs, wherein M is greater than or equal to 1, the original key value pairs support operation, and the types of the original key value pairs comprise objects;
the object processing module is used for analyzing the attribute in the object into new key value pairs under the condition that the original key value pairs with the types of objects exist in the M original key value pairs to obtain N first key value pairs, wherein the first key value pairs comprise original key value pairs with the types of non-objects and key value pairs obtained by analysis in the objects; n is greater than or equal to 1 and N is greater than or equal to M;
a first updating module, configured to calculate, according to types of the N first key-value pairs, values of the N first key-value pairs to obtain N updated second key-value pairs, where the values of the second key-value pairs include results of the operation; and
and the second updating module is used for updating M original key value pairs by using the N second key value pairs according to the incidence relation between the first key value pairs and the original key value pairs to obtain updated code text information, and the data format of the updated code text information is suitable for local equipment.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-9.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, carries out the method according to any one of claims 1 to 9.
CN202211195402.2A 2022-09-28 2022-09-28 Code text processing method, device, equipment and medium Pending CN115408008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211195402.2A CN115408008A (en) 2022-09-28 2022-09-28 Code text processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211195402.2A CN115408008A (en) 2022-09-28 2022-09-28 Code text processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN115408008A true CN115408008A (en) 2022-11-29

Family

ID=84167415

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211195402.2A Pending CN115408008A (en) 2022-09-28 2022-09-28 Code text processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115408008A (en)

Similar Documents

Publication Publication Date Title
CN109683953B (en) Method and device for processing configuration file based on visual interface
CN111506900B (en) Vulnerability detection method and device, electronic equipment and computer storage medium
CN111897842A (en) Data checking method, device, computer system and medium
CN114328208A (en) Code detection method and device, electronic equipment and storage medium
US10460019B2 (en) Computer implemented system and method for transforming web content for display on multiple form factors
CN107391528B (en) Front-end component dependent information searching method and equipment
CN115599386A (en) Code generation method, device, equipment and storage medium
CN109902726B (en) Resume information processing method and device
CN112954056B (en) Method and device for processing monitoring data, electronic equipment and storage medium
CN112596738B (en) Method and device for determining front-end page to be tested, storage medium and electronic equipment
CN112527302B (en) Error detection method and device, terminal and storage medium
CN116009852A (en) Code construction method, device, computer equipment and storage medium
CN115408008A (en) Code text processing method, device, equipment and medium
US11971807B2 (en) Software-development tool for presenting telemetry data with associated source code
CN113377648B (en) Software system diagnosis method, device, electronic equipment and computer readable medium
CN115408009A (en) Code file generation method, device, equipment and storage medium
CN116185805A (en) Code detection method, device, equipment and storage medium
CN110554892A (en) Information acquisition method and device
CN111382557B (en) Batch processing method, device, terminal and storage medium for non-fixed-length input data
CN111400623B (en) Method and device for searching information
CN113138767A (en) Code language conversion method, device, electronic equipment and storage medium
US11119761B2 (en) Identifying implicit dependencies between code artifacts
CN114490136A (en) Service calling and providing method, device, electronic equipment, medium and program product
CN111104626B (en) Information storage method and device
CN112287097B (en) Method and device for analyzing markup language text, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination