6

How can we convert YAML file to Application.properties?

pay.payment:
  sandbox:
   Url: https://securegw-stage//processTransaction
    callbackUrl: http://localhost:8080/pgresponse
    details:
      CHANNEL_ID: '${pay.payment.sandbox.channelid}'
      INDUSTRY_TYPE_ID: '${pay.payment.sandbox.industrytypeid}'
      CALLBACK_URL: '${pay.payment.sandbox.callbackUrl}'

Is there any tool to convert YAML to app.properties online?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Myjay1516
  • 197
  • 2
  • 4
  • 12
  • The format is called YAML and the recommended file extension for those files has beeen `.yaml` since 2006. – Anthon Nov 12 '18 at 15:58

2 Answers2

5

I dealt with the same problem using a python script.

Just clone and run:

$ python yaml2props.py {your_path_file}

Note

In my specific case on Ubuntu 18.04, I had to install pyperclip library and use python3, so:

$ pip3 install pyperclip
$ python3 yaml2props.py {your_path_file}
Reginaldo Santos
  • 840
  • 11
  • 24
3

The yml is a tree, to convert to a properties you just need the extra boilerplate of the preceding hierarchy e.g.

pay.payment.sandbox.url=https://securegw-stage//processTransaction
pay.payment.sandbox.callbackurl=http://localhost:8080/pgresponse
pay.payment.sandbox.details.CHANNEL_ID='${pay.payment.sandbox.channelid}'
pay.payment.sandbox.details.INDUTRY_TYPE_ID='${pay.payment.sandbox.industrytypeid}'
pay.payment.sandbox.details.CALLBACK_URL='${pay.payment.sandbox.callbackUrl}'
Darren Forsythe
  • 10,712
  • 4
  • 43
  • 54
  • Thanks for answering ,Btw can you tel me difference between pay.payment.sandbox.callbackurl=http://localhost:8080/pgresponse pay.payment.sandbox.details.CALLBACK_URL='${pay.payment.sandbox.callbackUrl}' – Myjay1516 Nov 12 '18 at 11:01
  • that's a placeholder, it will be expanded to the `callbackUrl` value. Wrapped in `'` I think – Darren Forsythe Nov 12 '18 at 12:15