0

I am trying to add JSONObject inside properties of segmentIO analytics but it is showing json as String on server.

Here is my code:

JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("abc", "xyz");
properties.putValue("extras", jsonObject);
Analytics.with(context).track(event, properties);

Output:

extras : "{"abc","xyz"}"

Expected Output:

extras : {"abc","xyz"}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Prashant Kedia
  • 318
  • 5
  • 14

1 Answers1

1

Use JSONParser (org.json.simple.parser.JSONParser)

JSONParser parser = new JSONParser();
JSONObject object = (JSONObject) parser.parse(json);
properties.putValue("extras", object);