New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception in thread "main" com.github.underscore.lodash.Json$ParseException: Expected value at 12:4 #234
Comments
Hi, I think |
No even if I removed those, things doesn't works. Could you please try ? |
Although I used I see errors.
|
I fixed json: {
"_embedded": {
"employeeDetails": [
{
"employeeNumber": "100",
"status": "A"
},
{
"billingNum": "200",
"status": "A"
}
]
},
"_links": {
"self": {
"href": "/employee/100/employees"
}
},
"page": {
"size": 25,
"totalElements": 11,
"totalPages": 1,
"number": 0
}
} Or java code: String json = "{\n"
+ " \"_embedded\": {\n"
+ " \"employeeDetails\": [\n"
+ " {\n"
+ " \"employeeNumber\": \"100\",\n"
+ " \"status\": \"A\"\n"
+ " },\n"
+ " {\n"
+ " \"billingNum\": \"200\",\n"
+ " \"status\": \"A\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"_links\": {\n"
+ " \"self\": {\n"
+ " \"href\": \"/employee/100/employees\"\n"
+ " }\n"
+ " },\n"
+ " \"page\": {\n"
+ " \"size\": 25,\n"
+ " \"totalElements\": 11,\n"
+ " \"totalPages\": 1,\n"
+ " \"number\": 0\n"
+ " }\n"
+ "}"; |
Hi, What did you change in the JSON? With the above code is working fine now ? |
Could you please share complete source code ? |
Here you are: import com.github.underscore.lodash.U;
import java.util.*;
public class JsonToXml2 {
public static void main(String[] args) {
String response = "<FinalResponse xmlns:ns5=\"urn:mybay.com:enterprise:schemas:common:elements\">\r\n" +
" <ns5:Type>SUCCESS</ns5:Type>\r\n" +
" <ns5:Code>0</ns5:Code>\r\n" +
"</FinalResponse>";
String xml ="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ " <soapenv:Header/>"
+ " <soapenv:Body>"
+ "<getMyData xmlns:ns10=\"urn:mybay.com:dms:wsdls:Visit\" xmlns:ns5=\"urn:mybay.com:enterprise:schemas:common:elements\" xmlns:ns6=\"urn:mybay.com:enterprise:schemas:Visit\" xmlns:ns7=\"urn:mybay.com:dms:schemas:Visit\" xmlns:ns8=\"urn:mybay.com:enterprise:schemas:account\">"
+ "<Visit>"
+ "<item>"
+ "</item>"
+ "</Visit>"
+ "</getMyData>"
+ response
+ "</soapenv:Body>"
+ "</soapenv:Envelope>";
Map<String, Object> map = (Map<String, Object>) U.fromXml(xml);
Map<String, Object> responsemap = (Map<String, Object>) U.fromXml(response);
String json = "{" +
" \"_embedded\": {" +
" \"employeeDetails\": [" +
" {" +
" \"employeeNumber\": \"100\"," +
" \"status\": \"A\"" +
" }," +
" {" +
" \"billingNum\": \"200\"," +
" \"status\": \"A\"" +
" }" +
" ]" +
" }," +
" \"_links\": {" +
" \"self\": {" +
" \"href\": \"/employee/100/employees\"" +
" }" +
" }," +
" \"page\": {" +
" \"size\": 25," +
" \"totalElements\": 11," +
" \"totalPages\": 1," +
" \"number\": 0" +
" }" +
"}";
Map<String, Object> map2 = (Map<String, Object>) U.fromJson(json);
U.set(map, "soapenv:Envelope.soapenv:Body.getMyData.Visit.item", map2);
System.out.println(U.toXml(map));
}
} |
Great, Many thanks for quick help, but I am not clear what did you change ? |
I fixed JSON and changed type for the |
In my case, I converted complex POJO to Map using Look like below code is unable to set it up. |
How to convert below JSON to XML ?
Error
The text was updated successfully, but these errors were encountered: