Search code examples
arraysjsonbasic-authentication

How to get a valid strings array in JSON format?


I have and string array in json format as follows, which I will be adding to my API header

[\"Authorization:\ Basic\ T1BFTlZJRFVBUFA6UmVzcG9uc2VARXllITIz\"]

But I get the below error when I try to restart my server which has the above property set in .env file

Property OPENVIDU_WEBHOOK_HEADERS=[\"Authorization:\ Basic
T1BFTlZJRFVBUFA6UmVzcG9uc2VARXllITIz\"]. Is not a valid strings array in JSON format. com.google.gson.stream.MalformedJsonException: Expected value at line 1 column 2 path $[0]

What would be the correct way to define the property?


Solution

  • It is to do with the escaping of your string.

    Correct String :

    ["Authorization: \"Basic T1BFTlZJRFVBUFA6UmVzcG9uc2VARXllITIz\""]