CN109460220A - The predefined code generating method of message, device, electronic equipment and storage medium - Google Patents

The predefined code generating method of message, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109460220A
CN109460220A CN201811220484.5A CN201811220484A CN109460220A CN 109460220 A CN109460220 A CN 109460220A CN 201811220484 A CN201811220484 A CN 201811220484A CN 109460220 A CN109460220 A CN 109460220A
Authority
CN
China
Prior art keywords
information
field
message
data
mapping set
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811220484.5A
Other languages
Chinese (zh)
Other versions
CN109460220B (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.)
Taikang Insurance Group Co Ltd
Taikang Pension Insurance Co Ltd
Original Assignee
Taikang Insurance Group Co Ltd
Taikang Pension Insurance 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 Taikang Insurance Group Co Ltd, Taikang Pension Insurance Co Ltd filed Critical Taikang Insurance Group Co Ltd
Priority to CN201811220484.5A priority Critical patent/CN109460220B/en
Publication of CN109460220A publication Critical patent/CN109460220A/en
Application granted granted Critical
Publication of CN109460220B publication Critical patent/CN109460220B/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/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present invention provides a kind of predefined code generating method of message, device, electronic equipment and storage medium and obtains field identification and field attribute information by the field data according to sample message;The corresponding object identity of field identification is obtained in object mapping set, object mapping set includes the object identity and object definition information for being used to indicate business object;According to field attribute information, the corresponding object definition information of object identity in object mapping set is determined;According to object definition information, generate or update the predefined code of message, it realizes and automated analysis is carried out to sample message, adaptive updates or the corresponding business object definition of creation, as message content is constantly updated and is enriched, the present invention can constantly correspondingly be improved the predefined code of existing message, or generate the new predefined code of message, the formation efficiency of the predefined code of message is improved, and then improves the efficiency and reliability serialized in message transmissions with unserializing.

Description

The predefined code generating method of message, device, electronic equipment and storage medium
Technical field
The present invention relates to the information processing technologies more particularly to a kind of predefined code generating method of message, device, electronics to set Standby and storage medium.
Background technique
With more and more abundant data transfer demands, the interface between system calls would generally be using the number such as XML or JSON The transmission of data message is carried out according to format.The detailed process of inter-system data transmission is transmitting terminal by the business object in memory The data message (serializing) for switching to XML or JSON, is transferred to after receiving end, and data message is then converted to business by receiving end Object is stored in content (unserializing).The predefined code of message is the key that serializing and unserializing process, it is therefore desirable to Improve the formation efficiency of the predefined code of message.
Under traditional mode, when carrying out data exchange using data message, communicating pair is required as used agreement Type and version carry out the corresponding predefined written in code of message, contain in the predefined code of message to various types of numbers According to the logical process mode of item.When having update in data message, developer is needed to carry out weight to original parsing code New design, needs largely to write new code.
However, information entrained by data message is more and more abundant with the development of information technology, the data of required parsing It measures increasing.Had been manually done during predefined written in code by developer's use exist develop cumbersome, heavy workload, The problems such as repetitive operation is more.The existing predefined code generating method of message is inefficient.
Summary of the invention
The present invention provides a kind of predefined code generating method of message, device, electronic equipment and storage medium, improves report The formation efficiency of the predefined code of text.
According to the first aspect of the invention, a kind of predefined code generating method of message is provided, comprising:
According to the field data of sample message, field identification and field attribute information are obtained;
The corresponding object identity of the field identification is obtained in object mapping set, the object mapping set includes using In the object identity and object definition information of instruction business object;
According to the field attribute information, the corresponding object definition of object identity described in the object mapping set is determined Information;
According to the object definition information, the predefined code of message is generated or updated.
Optionally, described that the word is obtained in object mapping set in a kind of possible implementation of first aspect The corresponding object identity of segment identification, comprising:
Judge the corresponding object identity of the field identification whether has been stored in object mapping set;
If judging to have stored the corresponding object identity of the field identification in the object mapping set, find pre- The object identity of storage;
If the corresponding object identity of the not stored field identification in the object mapping set is judged, described right As increasing the corresponding object identity of the field identification in mapping set.
Optionally, in the alternatively possible implementation of first aspect, the field attribute information includes: field type Information and daughter element information;
It is described find the pre-stored object identity after, it is described according to the field attribute information, determine institute State the corresponding object definition information of object identity described in object mapping set, comprising:
According to the corresponding field type information of the field identification and daughter element information, determine that the field identification is corresponding Sample defines information;
By the corresponding former object definition information of object identity described in the object mapping set, defines and believe with the sample Breath carries out diversity ratio pair, obtains and newly-increased defines information, wherein the newly-increased definition information be with the original object definition information not Identical sample defines information;
By the newly-increased definition information update into the former object definition information, institute in the object mapping set is obtained State the corresponding object definition information of object identity.
Optionally, in another possible implementation of first aspect, the field attribute information includes: field type Information and daughter element information;
It is described according to the word after increasing the corresponding object identity of the field identification in the object mapping set Section attribute information, determines the corresponding object definition information of object identity described in the object mapping set, comprising:
According to the corresponding field type information of the field identification and daughter element information, determine that the field identification is corresponding Sample defines information;
The sample is defined into information as the corresponding object definition letter of object identity described in the object mapping set Breath.
Optionally, in another possible implementation of first aspect, the field data according to sample message is obtained To field identification and field attribute information, comprising:
Sample message is obtained, and determines the message structure information of the sample message, the message structure information includes XML Format structure or JSON format structure;
According to the field data of the message structure information and the sample message, tree form data structure body is obtained, wherein Each node data of the tree form data structure body includes the field identification and field attribute information of the field data.
Optionally, in another possible implementation of first aspect, the field attribute information includes: field type Information and daughter element information;
The field data according in the message structure information and the sample message, obtains tree form data structure Body, comprising:
According to the message structure information, node location and number of nodes to each field data of the sample message are obtained According to, wherein the message structure information defines the subordinate relation between field data, and the node location indicates the Field Count According to the node of corresponding storage, the node data includes the field identification, field type information and daughter element of the field data Information;
According to the node location, each node data is stored into root node, child node or leaf node, is obtained Obtain tree form data structure body.
Optionally, described according to the message structure information in another possible implementation of first aspect, it obtains To the node location and node data of each field data of the sample message, comprising:
The top field data that the message structure information is defined is as target data;
The field identification of the target data is obtained, if including in the stored node data of sample message The field identification of target data is stated, then multiple labelling is written to the field type information of the target data, wherein the field Type information further includes the character length information of object type and the target data;
According to the message structure information, the subdata for being subordinated to the target data next stage is obtained;
The field type information of the subdata is obtained, and the mesh is determined according to the field type information of the subdata Mark the daughter element information of data;
According to the message structure information, the node location of the target data is determined, and by the field identification, described Field type information and the daughter element information, are stored as the node data of the node location;
If including the daughter element information of object type in the daughter element information, by the subdata of the object type As the target data, returns and execute the field identification for obtaining the target data.
Optionally, in another possible implementation of first aspect, the field type according to the subdata Information determines the daughter element information of the target data, comprising:
If the field type information of the subdata is sky, by can void type be determined as the daughter element of the target data Information;
If the field type information of the subdata includes text type, the target data is written into text type Daughter element information;
If the field type information of the subdata includes object type, the target data is written into object type Daughter element information.
Optionally, in another possible implementation of first aspect, the field data according to sample message is obtained To field identification and field attribute information, further includes:
Obtain the data origin information of the field attribute information;
It is described according to the field attribute information, determine the corresponding object of object identity described in the object mapping set Define information, further includes:
The object definition information is written into the data origin information.
According to the second aspect of the invention, a kind of predefined code generating unit of message is provided, comprising:
Message analysis module obtains field identification and field attribute information for the field data according to sample message;
Mapping building module, it is described for obtaining the corresponding object identity of the field identification in object mapping set Object mapping set includes the object identity and object definition information for being used to indicate business object;
Object definition module, for determining object described in the object mapping set according to the field attribute information Identify corresponding object definition information;
Code generation module, for generating or updating the predefined code of message according to the object definition information.
According to the third aspect of the invention we, a kind of electronic equipment is provided, comprising: memory, processor and computer journey Sequence, in the memory, the processor runs the computer program and executes first aspect for the computer program storage And the predefined code generating method of message described in the various possible implementations of first aspect.
According to the fourth aspect of the invention, a kind of storage medium is provided, is stored with and executes instruction in the storage medium, institute It states and executes instruction when being executed by processor for realizing report described in the various possible implementations of first aspect and first aspect The predefined code generating method of text.
A kind of predefined code generating method of message provided by the invention, device, electronic equipment and storage medium, pass through root According to the field data of sample message, field identification and field attribute information are obtained;The field is obtained in object mapping set Corresponding object identity is identified, the object mapping set includes the object identity and object definition letter for being used to indicate business object Breath;According to the field attribute information, the corresponding object definition information of object identity described in the object mapping set is determined; According to the object definition information, the predefined code of message is generated or is updated, realizes and automated analysis is carried out to sample message, Adaptive updates or the corresponding business object definition of creation, as message content is constantly updated and is enriched, the present invention can be continuous Correspondingly the predefined code of existing message is improved, or generates the new predefined code of message, it is pre- to improve message The formation efficiency of definition code, and then improve the efficiency and reliability serialized in message transmissions with unserializing.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to do simply to introduce, it should be apparent that, the accompanying drawings in the following description is the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 is a kind of application scenarios schematic diagram of the predefined code generating method of message provided in an embodiment of the present invention;
Fig. 2 is a kind of predefined code generating method flow diagram of message provided in an embodiment of the present invention;
Fig. 3 is a kind of sample message schematic diagram of XML format structure provided in an embodiment of the present invention;
Fig. 4 is the structural relation schematic diagram of the part field data of sample message shown in Fig. 3;
Fig. 5 is a kind of node data acquisition methods flow diagram provided in an embodiment of the present invention;
Fig. 6 is a kind of predefined code generating unit structural schematic diagram of message provided in an embodiment of the present invention;
Fig. 7 is the hardware structural diagram of a kind of electronic equipment provided in an embodiment of the present invention.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only It is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill Personnel's every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
It should be appreciated that the size of the serial number of each process is not meant to execute sequence in the various embodiments of the application It is successive, the execution of each process sequence should be determined by its function and internal logic, the implementation without coping with the embodiment of the present application Journey constitutes any restriction.
It should be appreciated that in this application, " comprising " and " having " and their any deformation, it is intended that covering is not arranged His includes, for example, the process, method, system, product or equipment for containing a series of steps or units are not necessarily limited to clearly Those of list step or unit, but may include be not clearly listed or for these process, methods, product or equipment Intrinsic other step or units.
It should be appreciated that in this application, " multiple " refer to two or more."and/or" is only a kind of description pass Join object incidence relation, indicate may exist three kinds of relationships, for example, and/or B, can indicate: individualism A is existed simultaneously These three situations of A and B, individualism B.Character "/" typicallys represent the relationship that forward-backward correlation object is a kind of "or".
It should be appreciated that in this application, " B corresponding with A " indicates that B is associated with A, B can be determined according to A.It is true according to A Determine B to be not meant to determine B only according to A, can also determine B according to A and/or other information.The matching of A and B is A and B Similarity is greater than or equal to preset threshold value.
Depending on context, as used in this " if " can be construed to " ... when " or " when ... " or " in response to determination " or " in response to detection ".
Technical solution of the present invention is described in detail with specifically embodiment below.These specific implementations below Example can be combined with each other, and the same or similar concept or process may be repeated no more in some embodiments.
It is a kind of application scenarios signal of the predefined code generating method of message provided in an embodiment of the present invention referring to Fig. 1 Figure.Carried out data transmission in the form of message between user terminal 1 and user terminal 2 as described in Figure.It is sent in data from user terminal 1 Before user terminal 2, user terminal 1 and user terminal 2 are raw with the predefined code of message in the following various embodiments of the present invention in advance At method, the predefined code of message is generated using sample message.Sample message can be what developer write.It is transmitted in data In the process, user terminal 1 carries out serializing treatment process to the data to be transmitted using the pre-generated predefined code of message, will Building obtains message and is sent to user terminal 2 by wire transmission mode or wireless transmission method.User terminal 2 utilizes pre-generated The predefined code of message carries out unserializing processing to the message received, and parsing obtains the data content in message.
It referring to fig. 2, is a kind of predefined code generating method flow diagram of message provided in an embodiment of the present invention, Fig. 2 The executing subject of shown method can be software and/or hardware device.It is specific as follows including step S101 to step S104:
S101 obtains field identification and field attribute information according to the field data of sample message.
The structure of sample message can be understood as including at least XML format structure and JSON format structure.
As a kind of optional implementation, field identification and field category can be stored by building tree form data structure body Property information.Specifically, sample message is obtained first, and determines the message structure information of the sample message, the message structure Information includes XML format structure or JSON format structure.Since although XML format structure and JSON format structure are all tree-like knots The message structure of structure, but there are still differences on format and on information category, it is therefore desirable to it is obtained according to different message structures Get corresponding message structure information.
Then according to the field data of the message structure information and the sample message, tree form data structure body is obtained. Wherein, each node data of the tree form data structure body includes the field identification and field attribute information of the field data. It is a kind of sample message schematic diagram of XML format structure provided in an embodiment of the present invention referring to Fig. 3.It referring to fig. 4, is shown in Fig. 3 The structural relation schematic diagram of the part field data of sample message.
Optionally, it includes: field type information and daughter element information that the field attribute information, which can be,.
Field type information is, for example, that the field is object type or text type.Wherein, object type refers to the word There are also subject matters under section.Daughter element information refers to the subject matter of present field.Such as Fig. 3 and message shown in Fig. 4 exist Include daughter element under " feedback request " (response) field: object code (result_code) is " 0 ", code information (message) for " success " and include more next stage daughter element declaration form object.Wherein, object code and code information Field type is text type, and the field type of declaration form object is object type.The message of XML format structure shown in Fig. 3, can To resolve to tree-like relationship shown in Fig. 4.Root node is " feedback request ", and the child node of the next stage of root node includes result generation Code, code information and declaration form object.Wherein, object code and code information are leaf node, without the son of more next stage Element, and it includes policy type (type), certificate number (policy_no), insurer's object that declaration form object, which also separates daughter element, (applicant) and other possible daughter elements.Policy type (type) and certificate number are leaf node.Insurer's object is made For the daughter element of object type, under include name, address object, mailbox, gender.Wherein, name, mailbox, gender are leaf Node.There are two address objects, and first address object includes address text, address style and number;Second address object Including address text and address style.
In above-mentioned implementation, the field data according in the message structure information and the sample message, A kind of realization process for obtaining tree form data structure body specifically may is that first according to the message structure information, obtain to described The node location and node data of each field data of sample message.Then according to the node location, by each number of nodes According to being stored into root node, child node or leaf node, tree form data structure body is obtained.
Wherein, the message structure information defines the subordinate relation between field data, and the message structure information can Be interpreted as under various format structures format information, syntax rule.It is corresponding that the node location indicates the field data The node of storage, the node data include the field identification, field type information and daughter element information of the field data.Word Segment identification can be field name, be also possible to Field ID.Such as it is Zhang San, word that a leaf node data, which include: field identification, Segment type information is text type, daughter element information is empty.
It is to be understood that node location and node data by determining each field, are then stored in tree data In structural body, the building of tree form data structure body is completed.It, can be in order to field identification by the tree form data structure body of building With the quick search and acquisition of field attribute information, the efficiency of message analysis is improved.
It is a kind of node data acquisition methods flow diagram provided in an embodiment of the present invention referring to Fig. 5.Optionally, exist It is described according to the message structure information during constructing tree form data structure body, obtain each word to the sample message The node location and node data of segment data can be to realize in a manner of each field in recursion cycle analysis message.Fig. 5 Shown in process specifically include and be not S201 to S208, it is specific as follows:
S201, the top field data that the message structure information is defined is as target data.
Such as " feedback request " in message shown in Fig. 3 and Fig. 4 is the top field data of the message, corresponds to root Node.The present embodiment is preferably the data for successively traversing each child node downwards from root node, until all traversing to leaf section Until point.
S202 obtains the field identification of the target data, if wrapping in the stored node data of sample message The field identification of the target data is included, then multiple labelling is written to the field type information of the target data.
Wherein, the field type information further includes the character length information of object type and the target data.It is more Heavy label is that appearance, such as address object, address text can be repeated as many times in same message for identifying the field data All it is to occur in same message 2 times with address style, multiple labelling should be written in its field type information, so as to To its accurate definition.
S203 obtains the subdata for being subordinated to the target data next stage according to the message structure information.
S204 obtains the field type information of the subdata, and is determined according to the field type information of the subdata The daughter element information of the target data.
Field type information can be understood as text type, object type and sky.The field type information of subdata is Sky indicates that current target data subordinate does not have daughter element, it can be understood as the daughter element under the object can fill out, such as Fig. 3 institute Show in the child node of address object, it is " 100123 " that traversal to first address object, which includes " number ", but second address Object corresponding " number " is sky, then the daughter element number coped in address object can be empty, the daughter element letter of writing address object In breath.
In an optional implementation manner, specific implementation may include:
If the field type information of the subdata is sky, by can void type be determined as the daughter element of the target data Information;
If the field type information of the subdata includes text type, the target data is written into text type Daughter element information;
If the field type information of the subdata includes object type, the target data is written into object type Daughter element information.
Step S202 and step S203-S204 is two independent processes in the present embodiment, not by described movement The limitation of sequence, step S202 can be performed in other orders or simultaneously with step S203-S204.
S205 determines the node location of the target data according to the message structure information, and by the field mark Knowledge, the field type information and the daughter element information, are stored as the node data of the node location.
The field type information and the daughter element information can be understood as above-mentioned field attribute information.It is stored as described The node data of node location can be understood as building tree form data structure body.
S206, judge in the daughter element information whether include object type daughter element information.If so, being transferred to S207;If being otherwise transferred to S208.
S207 is returned using the subdata of the object type as the target data and is executed S202.
It is to be understood that if being object type there are also daughter element, it is seen that the daughter element is not leaf node, need continue to It is lower to execute above-mentioned cyclic process.
S208 terminates.
It is to be understood that is, all branches have traversed leaf if not being object type in the daughter element information Child node completes the traversal of entire message, is transferred to S208 end loop.
S102 obtains the corresponding object identity of the field identification, the object mapping set in object mapping set Object identity and object definition information including being used to indicate business object.
As a kind of implementation, the acquisition of object identity it is specific it is to be understood that
Judge the corresponding object identity of the field identification whether has been stored in object mapping set, according to judging structure There can be following two different processing modes.
If having stored the corresponding object identity of the field identification in object mapping set, object mapping set is shown It is stored with the information of object identity instruction object, then finds the pre-stored object identity, realizes and searches object identity.
If showing object mapping set without storing the corresponding object identity of the field identification in object mapping set There are no the information of object identity instruction object, then it is corresponding right to increase the field identification in the object mapping set As mark, creation object identity is realized.
In the present embodiment, object mapping set can be understood as an object dictionary, for recording object and its definition Corresponding relationship.
S103 determines that object identity described in the object mapping set is corresponding right according to the field attribute information As defining information.
It is to be understood that the field attribute information includes: field type information and daughter element information.
It has been stored with the information of object identity instruction object in object mapping set, and has found the object identity In implementation, determine that the concrete mode of object definition information may is that first according to the corresponding field class of the field identification Type information and daughter element information determine that the corresponding sample of the field identification defines information.Sample is defined in information and also be can wrap Contain field identification, such as field name or code field etc..Then object identity described in the object mapping set is corresponding Former object definition information, define information with the sample and carry out diversity ratio pair, obtain and newly-increased define information, wherein is described new Increase and defines information to define information with the former different sample of object definition information.The newly-increased definition information is for example former to protect Address object only has 1 in single object, and address object can have 2 or multiple in new message, then increases newly and define packet Multiple labelling containing address object.The newly-increased definition information update is finally obtained into institute into the former object definition information State the corresponding object definition information of object identity described in object mapping set.There can also be object mark in object definition information Know, such as the information such as coding of NameSpace and/or object where object name, object, can be used for identifying the object definition The corresponding object of information.
It is not stored with the information of object identity instruction object in object mapping set, and creates the object identity In implementation, determine that the concrete mode of object definition information may is that first according to the corresponding field class of the field identification Type information and daughter element information determine that the corresponding sample of the field identification defines information.Then directly the sample is defined Information is as the corresponding object definition information of object identity described in the object mapping set.
In above-mentioned various implementations, for each field data of more clearly defined message, step S101 (according to The field data of sample message obtains field identification and field attribute information), it can also include: to obtain the field attribute letter The data origin information of breath.Data origin information for example get insurer's object field identification and field attribute information it is same When or before, or later, the data source of insurer's object, the i.e. position of guarantor's object field data in messages can also be obtained It sets.Position in messages can be embodied with parameter name.
On the basis of obtaining data origin information, S103 (according to the field attribute information, determines that the object reflects Penetrate the corresponding object definition information of object identity described in set) it also can also include: that institute is written into the data origin information State object definition information.To improve the accuracy of object definition information.
S104 generates or updates the predefined code of message according to the object definition information.
The predefined code of message can be the code of C language or Java language, can carry out corresponding language according to actual needs The predefined code building of the message of speech.Specifically, a certain subclass that ClassFile GeneratorBase can be used, by institute It states object definition information and generates the predefined code of message.In specifically generating the predefined code of new message, or old The predefined code of message is done when updating, and the daughter element sample data of each object can be generated corresponding annotation in code, To facilitate developer with reference to use.
Such as the predefined code generated corresponding for code information in Fig. 3 and Fig. 4, it can be as follows:
*************************************************************
///<summary>
///message (must be filled out)
///example:[success]
///</summary>
///<example>[success]</example>
[XmlElement (ElementName=" message ", Namespace=" ")]
public string message{get;set;}
*************************************************************
It is above-mentioned to be used as in the predefined code of exemplary message, [XmlElement (ElementName=" message ", Namespace=" ")] define data source;public string message{get;set;Define code information.
The predefined code generating method of a kind of message provided in this embodiment, by the field data according to sample message, Obtain field identification and field attribute information;The corresponding object identity of the field identification, institute are obtained in object mapping set Stating object mapping set includes the object identity and object definition information for being used to indicate business object;Believed according to the field attribute Breath, determines the corresponding object definition information of object identity described in the object mapping set;According to the object definition information, The predefined code of message is generated or updated, realizes and automated analysis is carried out to sample message, adaptive updates or creation correspond to Business object definition, as message content is constantly updated and abundant, the present invention can be constantly correspondingly pre- to existing message Definition code improves, or generates the new predefined code of message, improves the formation efficiency of the predefined code of message, into And improve the efficiency and reliability serialized in message transmissions with unserializing.
The predefined code of message that above-described embodiment generates can be used for during serialization process and unserializing, by dividing Analyse message structure, find all objects present in message, even if same target repeatedly occurs, can by multiple labelling and The modes such as field identification are distinguished and are merged, and the efficiency of interface docking exploitation in data transmission are improved, to improve report The efficiency of text parsing and building.
As a kind of optional implementation, in above-mentioned various embodiments can by call following various object functions come Realize corresponding step.
DataAnalyzor: abstract class obtains object structure definition for defining the analysis from various messages.From such The XmlAnalyzor and JsonAnalyzor of derivation are respectively used to the analysis of XML and JSON message.
ClassFileGeneratorBase: abstract class generates different programming languages from object structure definition for defining Call the turn object definition code.From the CSharpGenerator and JavaGenerator of such middle derivation be respectively used to generate C# and The predefined code of the message of JAVA language.
ClassesInfo: being a set, there is defined the business object members for development language neutrality to define letter Breath.The set of object ClassDef is defined including class, NameSpace defines the set of object NameSpaceDef.
ClassDef: to the definition information of business object.Which includes the information of business object (such as object marks itself Know), and including attribute information define the set of PropertyDef.
PropertyDef: to the attribute definition information of business object.Include Property Name, type, multiplicity, can be empty Property etc. definition.
It is a kind of predefined code generating unit structural schematic diagram of message provided in an embodiment of the present invention referring to Fig. 6.Fig. 6 Shown in the predefined code generating unit 60 of message specifically include that
Message analysis module 61 obtains field identification and field attribute information for the field data according to sample message;
Mapping building module 62, for obtaining the corresponding object identity of the field identification, institute in object mapping set Stating object mapping set includes the object identity and object definition information for being used to indicate business object;
Object definition module 63, for according to the field attribute information, it to be right described in the object mapping set to determine As identifying corresponding object definition information;
Code generation module 64, for generating or updating the predefined code of message according to the object definition information.
The predefined code generating unit 60 of the message of embodiment illustrated in fig. 6 accordingly can be used for executing the reality of method shown in Fig. 2 The step in example is applied, it is similar that the realization principle and technical effect are similar, and details are not described herein again.
Optionally, the mapping building module 62 is specifically used for:
Judge the corresponding object identity of the field identification whether has been stored in object mapping set;If so, searching To the pre-stored object identity;If it is not, then increasing the corresponding object of the field identification in the object mapping set Mark.
Optionally, the field attribute information includes: field type information and daughter element information.Mould is constructed in the mapping After block 62 finds the pre-stored object identity, the object definition module 63 is used for:
According to the corresponding field type information of the field identification and daughter element information, determine that the field identification is corresponding Sample defines information;By the corresponding former object definition information of object identity described in the object mapping set, with the sample It defines information and carries out diversity ratio pair, obtain and newly-increased define information, wherein the newly-increased definition information is and the original object definition The different sample of information defines information;By the newly-increased definition information update into the former object definition information, institute is obtained State the corresponding object definition information of object identity described in object mapping set.
Optionally, the field attribute information includes: field type information and daughter element information.Mould is constructed in the mapping After block 62 increases the corresponding object identity of the field identification in the object mapping set, the object definition module 63 For:
According to the corresponding field type information of the field identification and daughter element information, determine that the field identification is corresponding Sample defines information;The sample is defined information as the corresponding object of object identity described in the object mapping set to determine Adopted information.
Optionally, the message analysis module 61 is used for:
Sample message is obtained, and determines the message structure information of the sample message, the message structure information includes XML Format structure or JSON format structure;According to the field data of the message structure information and the sample message, obtain tree-like Data structure, wherein each node data of the tree form data structure body includes the field identification and word of the field data Section attribute information.
Optionally, the field attribute information includes: field type information and daughter element information.The message analysis module 61 are used for:
According to the message structure information, node location and number of nodes to each field data of the sample message are obtained According to, wherein the message structure information defines the subordinate relation between field data, and the node location indicates the word The node of the corresponding storage of segment data, the node data includes the field identification, field type information and son of the field data Element information;According to the node location, each node data is stored into root node, child node or leaf node, Obtain tree form data structure body.
Optionally, the message analysis module 61 is specifically used for: the top field that the message structure information is defined Data are as target data;
The field identification of the target data is obtained, if including in the stored node data of sample message The field identification of target data is stated, then multiple labelling is written to the field type information of the target data, wherein the field Type information further includes the character length information of object type and the target data;According to the message structure information, obtain Take the subdata for being subordinated to the target data next stage;The field type information of the subdata is obtained, and according to the son The field type information of data determines the daughter element information of the target data;According to the message structure information, determine described in The node location of target data, and by the field identification, the field type information and the daughter element information, it is stored as institute State the node data of node location;It, will be described right if in the daughter element information including the daughter element information of object type As the subdata of type is as the target data, the return execution field identification for obtaining the target data.
Optionally, the message analysis module 61 is specifically used for:, will if the field type information of the subdata is sky Can void type be determined as the daughter element information of the target data;
If the field type information of the subdata includes text type, the target data is written into text type Daughter element information;
If the field type information of the subdata includes object type, the target data is written into object type Daughter element information.
Optionally, message analysis module 61 is also used to:
Obtain the data origin information of the field attribute information.
Correspondingly, the object definition module 63 is also used to:
The object definition information is written into the data origin information.
It is the hardware structural diagram of a kind of electronic equipment provided in an embodiment of the present invention referring to Fig. 7, the electronic equipment 70 It include: processor 71, memory 72 and computer program;Wherein
Memory 72, for storing the computer program, which can also be flash memory (flash).The calculating Machine program is, for example, to realize application program, the functional module etc. of the above method.
Processor 71, for executing the computer program of the memory storage, to realize each step in the above method Suddenly.It specifically may refer to the associated description in previous methods embodiment.
Optionally, memory 72 can also be integrated with processor 71 either independent.
When the memory 72 is independently of the device except processor 71, the electronic equipment can also include:
Bus 73, for connecting the memory 72 and processor 71.
The present invention also provides a kind of readable storage medium storing program for executing, computer program is stored in the readable storage medium storing program for executing, it is described The method provided when computer program is executed by processor for realizing above-mentioned various embodiments.
Wherein, readable storage medium storing program for executing can be computer storage medium, be also possible to communication media.Communication media includes just In from a place to any medium of another place transmission computer program.Computer storage medium can be general or special Any usable medium enough accessed with computer capacity.For example, readable storage medium storing program for executing is coupled to processor, to enable a processor to Information is read from the readable storage medium storing program for executing, and information can be written to the readable storage medium storing program for executing.Certainly, readable storage medium storing program for executing can also be with It is the component part of processor.Processor and readable storage medium storing program for executing can be located at specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC) in.In addition, the ASIC can be located in user equipment.Certainly, Processor and readable storage medium storing program for executing can also be used as discrete assembly and be present in communication equipment.Readable storage medium storing program for executing can be read-only Memory (ROM), random access memory (RAM), CD-ROM, tape, floppy disk and optical data storage devices etc..
The present invention also provides a kind of program product, the program product include execute instruction, this execute instruction be stored in it is readable In storage medium.At least one processor of equipment can read this from readable storage medium storing program for executing and execute instruction, at least one processing Device executes this and executes instruction so that equipment implements the method that above-mentioned various embodiments provide.
In the embodiment of above-mentioned electronic equipment, it should be appreciated that processor can be central processing unit (English: Central Processing Unit, referred to as: CPU), it can also be other general processors, digital signal processor (English: Digital Signal Processor, referred to as: DSP), specific integrated circuit (English: Application Specific Integrated Circuit, referred to as: ASIC) etc..General processor can be microprocessor or the processor is also possible to any conventional place Manage device etc..It can be embodied directly in hardware processor in conjunction with the step of the method disclosed in the present and execute completion or use Hardware and software module combination in reason device execute completion.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution The range of scheme.

Claims (10)

1. a kind of predefined code generating method of message characterized by comprising
According to the field data of sample message, field identification and field attribute information are obtained;
The corresponding object identity of the field identification is obtained in object mapping set, the object mapping set includes for referring to Show the object identity and object definition information of business object;
According to the field attribute information, the corresponding object definition letter of object identity described in the object mapping set is determined Breath;
According to the object definition information, the predefined code of message is generated or updated.
2. the method according to claim 1, wherein described obtain the field identification in object mapping set Corresponding object identity, comprising:
Judge the corresponding object identity of the field identification whether has been stored in the object mapping set;
If judging to have stored the corresponding object identity of the field identification in the object mapping set, storage is found The object identity;
If judging the corresponding object identity of the not stored field identification in the object mapping set, reflected in the object It penetrates in set and increases the corresponding object identity of the field identification.
3. according to the method described in claim 2, it is characterized in that, the field attribute information include: field type information and Daughter element information;
It is described find the pre-stored object identity after, described according to the field attribute information, it is described right to determine The corresponding object definition information of the object identity as described in mapping set, comprising:
According to the corresponding field type information of the field identification and daughter element information, the corresponding sample of the field identification is determined Define information;
By the corresponding former object definition information of object identity described in the object mapping set, with the sample define information into Row diversity ratio pair obtains newly-increased definition information, wherein the newly-increased definition information is not identical as the former object definition information Sample define information;
By the newly-increased definition information update into the former object definition information, it is right described in the object mapping set to obtain As identifying corresponding object definition information.
4. according to the method described in claim 2, it is characterized in that, the field attribute information include: field type information and Daughter element information;
It is described according to the field category after increasing the corresponding object identity of the field identification in the object mapping set Property information, determines the corresponding object definition information of object identity described in the object mapping set, comprising:
According to the corresponding field type information of the field identification and daughter element information, the corresponding sample of the field identification is determined Define information;
The sample is defined into information as the corresponding object definition information of object identity described in the object mapping set.
5. the method according to claim 1, wherein the field data according to sample message, obtains field Mark and field attribute information, comprising:
Sample message is obtained, and determines the message structure information of the sample message, the message structure information includes XML format Structure or JSON format structure;
According to the field data of the message structure information and the sample message, tree form data structure body is obtained, wherein described Each node data of tree form data structure body includes the field identification and field attribute information of the field data.
6. according to the method described in claim 5, it is characterized in that, the field attribute information include: field type information and Daughter element information;
The field data according in the message structure information and the sample message, obtains tree form data structure body, packet It includes:
According to the message structure information, node location and node data to each field data of the sample message are obtained, Wherein, the message structure information defines the subordinate relation between field data, and the node location indicates the field data The node of corresponding storage, the node data include field identification, field type information and the daughter element letter of the field data Breath;
According to the node location, each node data is stored into root node, child node or leaf node, is set Graphic data structural body.
7. according to the method described in claim 6, acquisition is to described it is characterized in that, described according to the message structure information The node location and node data of each field data of sample message, comprising:
The top field data that the message structure information is defined is as target data;
The field identification of the target data is obtained, if including the mesh in the stored node data of sample message Multiple labelling, then is written the field type information of the target data, wherein the field type by the field identification for marking data Information further includes the character length information of object type and the target data;
According to the message structure information, the subdata for being subordinated to the target data next stage is obtained;
The field type information of the subdata is obtained, and the number of targets is determined according to the field type information of the subdata According to daughter element information;
According to the message structure information, the node location of the target data is determined, and by the field identification, the field Type information and the daughter element information, are stored as the node data of the node location;
If in the daughter element information including the daughter element information of object type, using the subdata of the object type as The target data returns and executes the field identification for obtaining the target data.
8. a kind of predefined code generating unit of message characterized by comprising
Message analysis module obtains field identification and field attribute information for the field data according to sample message;
Mapping building module, for obtaining the corresponding object identity of the field identification, the object in object mapping set Mapping set includes the object identity and object definition information for being used to indicate business object;
Object definition module, for determining object identity described in the object mapping set according to the field attribute information Corresponding object definition information;
Code generation module, for generating or updating the predefined code of message according to the object definition information.
9. a kind of electronic equipment characterized by comprising memory, processor and computer program, the computer program In the memory, the processor runs the computer program perform claim and requires 1~7 any message for storage Predefined code generating method.
10. a kind of storage medium, which is characterized in that be stored with and execute instruction in the storage medium, described execute instruction is located It manages when device executes for realizing any predefined code generating method of message of claim 1~7.
CN201811220484.5A 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium Active CN109460220B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811220484.5A CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811220484.5A CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109460220A true CN109460220A (en) 2019-03-12
CN109460220B CN109460220B (en) 2022-04-12

Family

ID=65607844

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811220484.5A Active CN109460220B (en) 2018-10-19 2018-10-19 Message predefined code generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109460220B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111930612A (en) * 2020-07-09 2020-11-13 北京皮尔布莱尼软件有限公司 Method and device for detecting code updating correctness and computing equipment
CN112055018A (en) * 2020-09-03 2020-12-08 中国银行股份有限公司 Message analysis method and device
CN112671842A (en) * 2020-12-08 2021-04-16 成都质数斯达克科技有限公司 Information transmission method and device, electronic equipment and readable storage medium
CN112698819A (en) * 2019-10-22 2021-04-23 北京信普飞科科技有限公司 Method, device and storage medium for designing tree-oriented object programming program
CN113268306A (en) * 2021-06-08 2021-08-17 金蝶软件(中国)有限公司 Resume parsing interface calling method and device and computer storage medium
WO2022151835A1 (en) * 2021-01-18 2022-07-21 中国民航信息网络股份有限公司 Sample message processing method and apparatus
CN115168365A (en) * 2022-09-01 2022-10-11 浪潮通信信息系统有限公司 Data storage method and device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622444A (en) * 2012-03-15 2012-08-01 深圳市同洲视讯传媒有限公司 XML (extensible markup language) message processing method and XML message processing device
CN106598581A (en) * 2016-12-06 2017-04-26 成都能通科技有限公司 ASTERIX message parsing code generation method based on XML

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622444A (en) * 2012-03-15 2012-08-01 深圳市同洲视讯传媒有限公司 XML (extensible markup language) message processing method and XML message processing device
CN106598581A (en) * 2016-12-06 2017-04-26 成都能通科技有限公司 ASTERIX message parsing code generation method based on XML

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698819A (en) * 2019-10-22 2021-04-23 北京信普飞科科技有限公司 Method, device and storage medium for designing tree-oriented object programming program
CN111930612A (en) * 2020-07-09 2020-11-13 北京皮尔布莱尼软件有限公司 Method and device for detecting code updating correctness and computing equipment
CN111930612B (en) * 2020-07-09 2024-03-19 北京皮尔布莱尼软件有限公司 Code updating correctness detection method and device and computing equipment
CN112055018A (en) * 2020-09-03 2020-12-08 中国银行股份有限公司 Message analysis method and device
CN112055018B (en) * 2020-09-03 2023-05-23 中国银行股份有限公司 Message analysis method and device
CN112671842A (en) * 2020-12-08 2021-04-16 成都质数斯达克科技有限公司 Information transmission method and device, electronic equipment and readable storage medium
CN112671842B (en) * 2020-12-08 2022-07-12 成都质数斯达克科技有限公司 Information transmission method and device, electronic equipment and readable storage medium
WO2022151835A1 (en) * 2021-01-18 2022-07-21 中国民航信息网络股份有限公司 Sample message processing method and apparatus
CN113268306A (en) * 2021-06-08 2021-08-17 金蝶软件(中国)有限公司 Resume parsing interface calling method and device and computer storage medium
CN113268306B (en) * 2021-06-08 2024-03-19 金蝶软件(中国)有限公司 Resume analysis interface calling method and device and computer storage medium
CN115168365A (en) * 2022-09-01 2022-10-11 浪潮通信信息系统有限公司 Data storage method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN109460220B (en) 2022-04-12

Similar Documents

Publication Publication Date Title
CN109460220A (en) The predefined code generating method of message, device, electronic equipment and storage medium
US10630614B2 (en) Opaque message parsing
CN105094754B (en) Program developing method, page request response method and its device based on label
CN105760534B (en) Data structure, hadoop cluster, server and its application method of customized serializability
CN110688122B (en) Method and device for compiling and executing intelligent contract
CN110704064B (en) Method and device for compiling and executing intelligent contract
CN109375922A (en) A kind of automatic generation method and terminal device of interface document
CN110597814B (en) Structured data serialization and deserialization method and device
CN110704063A (en) Method and device for compiling and executing intelligent contract
CN109343836B (en) Data serialization and data deserialization method, device and equipment
WO2023124425A1 (en) Data processing method and apparatus, electronic device, and storage medium
CN104320312A (en) Network application safety test tool and fuzz test case generation method and system
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
EP4141690A1 (en) Automated transformation of hierarchical data from a source data format to a target data format
CN109325217B (en) File conversion method, system, device and computer readable storage medium
CN114995859A (en) Page hot updating method, device, equipment and storage medium
CN109144514B (en) JSON format data analysis and storage method and device
CN114168149A (en) Data conversion method and device
CN114201756A (en) Vulnerability detection method and related device for intelligent contract code segment
CN113961768A (en) Sensitive word detection method and device, computer equipment and storage medium
CN101944133A (en) XML metadata objectification analytic method and system
CN110941655A (en) Data format conversion method and device
CN110633162B (en) Remote call implementation method and device, computer equipment and storage medium
CN111061927B (en) Data processing method and device and electronic equipment
CN105793842B (en) Conversion method and device between serialized message

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
GR01 Patent grant
GR01 Patent grant