papakias papakias - 1 month ago 11x
JSON Question

How can I put JSON object in setQueryParameter parameters?

In Mobilefirst Platform 8.0, in order to send a request to an adapter procedure I can use something like this

resourceRequest.setQueryParameter("params", "['Washington', 'United States']");

But this is for 2 string values. How can I send a JSON object instead of a string?

I would like to send something like this:

var request = {name: 'George', suername: 'Williams', Id: '1234'};
resourceRequest.setQueryParameter("params", request);

If yes, what is the correct syntax?


Try the following approaches:

  1. Pass it directly, but as a string...

    resourceRequest.setQueryParameter("params", “[{’name’ : ‘bob’, ‘’age’ : 25}, 'United States']");
  2. Create a JSONArray and pass it

    JSONArray params = new JSONArray();
    resourceRequest.setQueryParameter("params", params);