Java JSONObject does not maintaing the order of which I put things into. Trying to send into WCF service -
this weird issue. understand json supposed unordered , implementation of java.lang.jsonobject mentions unordered.
however, puzzles me because expect way call put(); methods should keep order. maybe contradicts said in beginning though.
i using json communicate wcf web service requires me include __type key designate type of complex object sending.
i urge try this:
jsonobject object = new jsonobject(); try { object.put("__type", "value1"); object.put("secondkey", "value2"); object.put("thirdkey", "value3"); } catch (jsonexception e) { e.printstacktrace(); }
the output in log is: {"thirdkey":"value3","__type":"value1","secondkey":"value2"}
now, understand implementation uses hashmap , order not maintained. when calling wcf service key __type required first deserialization occur on service. how can achieve this? sometime, have been using plain strings send webservice works fine. however, not acceptable ugly , hard maintain.
please advice, either java side or wcf side how can tackle problem.
thanks!
however, puzzles me because expect way call put(); methods should keep order. maybe contradicts said in beginning though.
yes does.
but when calling wcf service key __type required first deserialization occur on service.
if true, (imo) either bug in service implementation or (if deserialization mechanism generic wcf) in wcf. in former case, complain service implementor service buggy. in latter case, try complaining microsoft breaking standards (yet again) ... you'd wasting breath.
the correct place fix in code on wcf side doing deserialization. in practice, may need switch different java json library serializes in way makes wcf happy. or maybe hack json library using ...
Comments
Post a Comment