E
E
Egor Petrov2015-10-28 13:42:53
API
Egor Petrov, 2015-10-28 13:42:53

How to describe data structure transformation?

Example, we need to make an API request. We have a set of data, card number, phone, address and so on.
Let's say one API accepts data in the form:

<card>345354345</card>
<phone>456456456</phone>
<address>dgfdgdfgf</address>

Another needs only the card number and it is called differently:
<card_number>345354345</card_number>
The third one has the main field, and all the rest are required, but not the main ones, and the field names are also different:
<pay_to>345354345</pay_to>
<extra>
<call_to>456456456</call_to>
<location>dgfdgdfgf</location>
</extra>

The fourth additional data is expected in the form of attribute values:
<card>345354345</card>
<extra phone="456456456" address="dgfdgdfgf">

And the fifth has two main parameters:
<main>
<pay_to>345354345</pay_to>
<pay_to_alter>676556767</pay_to_alter>
</main>
<extra>
<call_to>456456456</call_to>
<location>dgfdgdfgf</location>
</extra>

All this is not necessarily xml, it is both json and yaml and whatever.
The question is - how can we describe the information we have and how to describe its transformations, so that without unnecessary headaches when a new sophisticated format appears, it can be described without changing the source data and without changing the code?
What are the common solutions for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-10-28
@Rsa97

IMHO, the best option is to provide for the connection of plugin libraries, from the side of your application, receiving and issuing data in a single format for the application, and exchanging with third-party APIs in their format.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question