1

I want to parse a windows path in java. this is part of the json:

..."sslkey":"c:\usr\ssl\key.jks"

and this is the code:

JsonObject jsonargs = gson.fromJson(args[0], JsonObject.class);
SSLKEY = jsonargs.get("sslkey").getAsString();

I tried with \ also in the value, but the error that I have is:

Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 133 path $.sslkey

Could you please tell me how I can fix this?

Thank you !

biruk1230
  • 3,042
  • 4
  • 16
  • 29
Vasilev
  • 87
  • 1
  • 9
  • Does this answer your question? [How to escape forward slash in java so that to use it in path](https://stackoverflow.com/questions/24643025/how-to-escape-forward-slash-in-java-so-that-to-use-it-in-path) – Ssr1369 Nov 08 '19 at 10:11
  • `{"sslkey": "c:\usr\ssl\key.jks"}` - is not a valid `JSON`. You can `replace` "\" char with `/` and try to deserialise after. – Michał Ziober Nov 08 '19 at 19:38

1 Answers1

0

Thank you, i tried many things , it seems that : is also special char. I used base64 encode in php and base64 decode in java.. so all fine :)

Vasilev
  • 87
  • 1
  • 9