# Andmemuundur README Most of the current functionalities are related to JSON re-mapping/re-formatting and are demonstrated in SAMPLE_REQUESTS.md file. Most of the sample requests there use existing templates from templates folder. For a few others extra example templates are located in templates_examples folder. For extra information one can also refer to src/test/java/rig/andmemuundur/service/JsonServiceTests.java which contains tests that also demonstrate these functionalities. Input output and templates for mapping between I/O for these test cases are in the src/test/java/rig/andmemuundur/resources/json subfolders. Most of the basic functionality for JSON mapping/conversions can be described by following template : ``` { "this_will_be_field_name_in_output":{ "$.input" :"$.this_is_field_name_in_input", } } ``` For mapping arrays some more complicated constructions are available to be used in templates : ``` { "array_name_in_output" : [ { "#.input_array": "$.array_name_in_input", "sort_property": "$.field_from_object_in_that_array", "sort_type": "date", "sort_date_format": "yyyy-MM-dd'T'HH:mm'Z'", "sort_order": "desc", "properties": { "field_name_in_array_object_in_output": "$.some_field_from_object_in_input_array", } ] } ``` Instead of "#.input_array" one might also see "from_property" field in templates. This should be considered a depreciated feature. For writing future templates "#.input_array" is strongly recommended as this would allow the same functionality and more. For more detailed examples showing more complicated structures SAMPLE_REQUEST.md and its used templates should be consulted. Also there are examples for data conversion functionalities at the end of this file. Functionality of endpoint json/v1/convert that is also demonstrated in SAMPLE_REQUESTS.md does right now not use the general template based configuration. Currently only conversion of HTML-string to (base64 encoded) PDF is implemented. Fore extra information about this one can also refer to related tests src/test/java/rig/andmemuundur/service/PdfServiceTests.java Internal functionalities examples.Some of which are also covered in the JSON transformations example in SAMPLE_REQUESTS.md. Transform date format. ``` { "string_to_date": { "$.input": "$.aeg", "input_format": "dd-MM-yyyy HH:mm:ss.SSS", "type": "date", "format": "dd.MM.yyyy" } } ``` Integer json to string json and vice versa ``` { "int_to_string": { "$.input": "$.int_to_string", "type": "string" }, "string_to_int": { "$.input": "$.string_to_int", "type": "integer" } } ``` String json to decimal json, decimal json with scale, Decimal json to string json or integer json ``` { "str_to_decimal": { "$.input": "$.str_to_decimal", "type": "decimal" }, "str_to_decimal_scale": { "$.input": "$.str_to_decimal", "type": "decimal", "scale": 2 }, "decimal_to_str": { "$.input": "$.decimal_to_str", "type": "string" }, "decimal_to_integer": { "$.input": "$.decimal_to_integer", "type": "integer" } } ``` String json to boolean and vice versa ``` { "str_to_bln": { "$.input": "$.str_to_bln", "type": "boolean" }, "bln_to_str": { "$.input": "$.bln_to_str", "type": "string" } } ```