1

I have a .yml file like this in my gitlab server

   holidays:  
   US:  
     - 03/19/2020  
     - 03/20/2020  
     - 05/18/2020

the config server reads the above yml and returns something the response like this

{"name":"*****","profiles":["simpleyml"],"label":null,"version":"*****","state":null,"propertySources":[{"name":"https://*****.com/****.git/application-simpleyml.yml",source":{"holidays.US[0]":"03/19/2020","holidays.US[1]":"03/20/2020"}

I would need the config server to return the "source" part like the below instead

{"name":"*****","profiles":["simpleyml"],"label":null,"version":"*****","state":null,"propertySources":[{"name":"https://*****.com/****.git/application-simpleyml.yml","source":
  {
    "holidays": {
      "US": [
        "03/19/2020",
        "03/20/2020"
       ]
    }
  }

Could someone please help me out on this?

VJohn
  • 493
  • 1
  • 14
  • 23

1 Answers1

0

Try this out

Input YAML

source:
 holidays:
  US:
    - 03/19/2020
    - 03/20/2020

Returned JSON

{ "source": { "holidays": { "US": [ "03/19/2020", "03/20/2020" ] } } }

I think this matches your requirement

  • I am not able to find difference, can you point what's the difference between your requirement and what I have posted – Shivendra Tiwari Jul 30 '20 at 16:40
  • Thanks for this. but its the same output another ex: my yml file application-simpleyml.yml ----- holidays: US: city ----- Spring config server returns ---------------------- {"name":"*****","profiles":["simpleyml"],"label":null,"version":"***","state":null,"propertySources":[{"name":"https://*****.com/****.git/application-simpleyml.yml","source":{"holidays.US":"city"}}]} ------------- See the source content.. the Yaml path is still resolved.. What i need is something like this ----------- {"source":{"holidays": {"US":"city"}} ------- pls see the diff in source – VJohn Jul 30 '20 at 16:42
  • If you will directly request it from Spring Config Server output will come in this way only. Not possible to get just source. Only option is after getting the response parse the JSON. Spring Config Server is their to communicate with microservices only. – Shivendra Tiwari Jul 30 '20 at 16:48
  • Sorry, may be my question was confusing. basically, its not like i only need "source". Config server reads yaml and returns with resolved paths like "holidays.US:***" all i need is just avoid this resolving paths and return the content like this "holidays: { US: ** }} – VJohn Jul 30 '20 at 16:58