0

i am looking to find an example of Java-diff-utils finding the difference between two strings e.g.

String s1 = "{\"type\": \"message_typing\",\"requestId\": \"requestid\",\"clientMutationId\": \"mutationid\",\"chatRoomId\": \"roomid\",\"conversationId\": \"conversationid\"}";
String s2 = "{\"type\": \"type_2\",\"requestId\": \"1\",\"clientMutationId\": \"2\",\"chatRoomId\": \"dev/test\",\"conversationId\": \"aa2344ceDsea1\"}";

so the first is the base message the second is the one i would like to compare against the base message and get the different values (e.g. type_2,1,2,dev/test,aa2344ceDsea1) however i would like to be able to reassemble the string correctly if given only the base message and the values of the diffs.

I can only find examples using two files online and no examples using two strings if anyone could give me a code example that would be very helpful. I have already did it using google-diff-patch-match however the returned diffs are too large for what i need. as i will be sending the diffs over MQTT in order to keep payload size down, so i need something that can extract the values but still be able to reassemble on the other side when given the values and base message.

NC24
  • 1
  • 4
  • The second answer might be helpful: http://stackoverflow.com/questions/132478/how-to-perform-string-diffs-in-java?rq=1 – Ishnark Apr 06 '17 at 17:25
  • I have already been on that , more so just looking for a java-dii-utils example of two strings, thank you though – NC24 Apr 06 '17 at 20:01
  • This seems to be a solution: https://stackoverflow.com/questions/45166235/text-comparison-algorithm-or-program/45166480#45166480. – wumpz Jul 28 '17 at 12:00

0 Answers0