> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Script Görevi içinde resultMap ile Veri Aktarımı

> Script görevi içinde resultMap değişkeni ile farklı tipte veriler üretebilir ve bu verileri JSON formatında diğer süreçlere aktarabilir. Groovy dili ile text, JSON, XML, number ve date tipindeki verileri resultMap'e ekleyebilir.

```groovy theme={null}
import groovy.json.JsonSlurper
import groovy.util.XmlSlurper
import java.time.LocalDateTime
import java.time.LocalDate

resultMap.put("textSample", "text value");

def json='{ "name": "John", "surname":"Doe"}'
def object = new JsonSlurper().parseText(json)
resultMap.put("jsonObjectSample",object);

resultMap.put("jsonTextSample",'{ "name": "John", "surname":"Doe"}');

def xml='''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://schema.apinizer.com/Yardimci/EPosta/v1">
 <soapenv:Header/>
 <soapenv:Body>
 </soapenv:Body>
</soapenv:Envelope>''';
def Envelope = new XmlSlurper().parseText(xml);
resultMap.put("xmlObjectSample", object);
resultMap.put("xmlTextSample", xml);

resultMap.put("numberSample1", 100);
resultMap.put("numberSample2", 99.99);

// takes the date encoded as milliseconds since midnight, January 1, 1970 UTC
def date1 = new Date(System.currentTimeMillis())
resultMap.put("dateSample1", date1);

// create from an existing Calendar object
def date2 = new GregorianCalendar(2021, Calendar.APRIL, 3, 1, 23, 45).time
resultMap.put("dateSample2", date2);

LocalDate localDate=LocalDate.now()
resultMap.put("localDate", localDate);

LocalDateTime localDateTime = LocalDateTime.now();
resultMap.put("localDateTime", localDateTime);
```

Bu script çalıştığında resultMap JSON hali aşağıdaki örnek data gibi olacaktır.

```json theme={null}
[
  {
    "dateSample1": "2021-11-25T13:05:46.969+0000",
    "dateSample2": "2021-04-02T22:23:45.000+0000",
    "jsonObjectSample": {
      "name": "John",
      "surname": "Doe"
    },
    "jsonTextSample": "{ \"name\": \"John\", \"surname\":\"Doe\"}",
    "localDate": "2021-11-25",
    "localDateTime": "2021-11-25T16:05:46.983",
    "numberSample1": 100,
    "numberSample2": 99.99,
    "textSample": "text value",
    "xmlObjectSample": {
      "name": "John",
      "surname": "Doe"
    },
    "xmlTextSample": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://schema.apinizer.com/Yardimci/EPosta/v1\">\n <soapenv:Header/>\n <soapenv:Body>\n </soapenv:Body>\n</soapenv:Envelope>"
  }
]
```
