Reputation: 195
I want a Program which takes JSON file as input and Results JSON file. The input file contains like:
{"empname":"surname.firstname","department.name":"production","salary":11254.42}
The Output file must replace '.'(dot) with '_'(underscore) of the input JSON. The expecting Output:
{"empname":"surname_firstname","department_name":"production","salary":11254_42}
I want this program using JAVA, without using Serialization and Deserialization. Can any one help?
Upvotes: 0
Views: 58
Reputation: 42040
If you are using Java 7+:
String str = new String(Files.readAllBytes(Paths.get("in.json")), StandardCharsets.UTF_8)
.replace('.', '_');
Files.write(Paths.get("out.json"), str.getBytes("UTF-8"), StandardOpenOption.WRITE);
Upvotes: 1