I need to generate an xml from a Json object and I am able to do that successfully. However some of the keys in that json object look like this,
{
"UNIX":"/BIN/BASH",
"STATUS operation='remove'":"EXPIRED",
"USERS operation='remove'":"[MATT]",
"DATE operation='ADD'":"20-MAY-17",
"FIRST_NAME":"ABC",
}
So, when I am converting this Json to an xml, I am getting the xml as this,
<?xml version="1.0" encoding="UTF-8"?>
<user userid="abcid">
<UNIX>/BIN/BASH</UNIX>
<STATUS operation='remove'>EXPIRED</STATUS operation='remove'>
<USERS operation='remove'>[ILMT0004]</USERS operation='remove'>
<DATE operation='ADD'>20-APR-17</DATE operation='ADD'>
<FIRST_NAME>MATT</FIRST_NAME>
</user>
As you can see, the key in the json is getting generated as the start and the end tags in the xml, I want that operation='remove'
string only in the start tag.I don't need it in the end tag of the xml. The end tag should simply be like </DATE>
.
How I can get rid of any characters that are present after a space in the end tags using java?