0

I've come up with a doubt around JSON files.

So, we're building a test case for a GWT application. The data it feeds from is in JSON files generated from a SQL database.

When testing the methods that work with data, we do it from sources held in String files, so to keep integrity with the original data, we just clone the original JSON values in to a String with escape sequences.

The result of this being that if a JSON entry shows like this:

 {"country":"India","study_no":87}

The parsed result will come up like this in order for our tools to recognise them:

"[" + "{\"country\":\"India\",\"study_no\":87}" + "]"

The way we do it now is taking each JSON object and putting it between "" in IntelliJ, which automatically parses all double quotes in to escape sequences. This is ok if we only wanted a few objects, but What if we wanted a whole dataset?

So my question is, does anyone know or has created an opensource script to automate this tedious task?

Steven
  • 1,236
  • 1
  • 13
  • 37

1 Answers1

0

One thing you could do is to wrap window.escape() using JsInterop or JSNI. For example:

@JsType(isNative="true", name="window")
public class window {

public native String escape(String toBeEscape);

}

and then apply to your results.

zakaria amine
  • 3,412
  • 2
  • 20
  • 35
  • Thank you, I will definitely try this, but just at the moment I have a bigger fight with maven (any expertise there?) http://stackoverflow.com/questions/39453454/maven-testing-gwttest – Steven Sep 12 '16 at 15:21