-2

I need to create the following JsonObject using JAVA:

{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:BulkRequest"],
    "Operations": [{
        "method": "DELETE",
        "path": "/Users/955ec8cd2bfc4af8998f6f5655d3bde8?forceDelete=true"
    }, {
        "method": "DELETE",
        "path": "/Users/97c46f642a084570a9c2fe959f8d14b3?forceDelete=true"
    }, {
        "method": "DELETE",
        "path": "/Users/cce146e8092a4458b1297a9ebb82e980?forceDelete=true"
    }]
}

I am unable to create the exact JsonObject.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • 5
    What did you try that didn't work? add that code please – Jack Flamp Aug 31 '18 at 11:21
  • I improved wording and formatting of your question, but I agree with the comments: A) this is most likely duplicate, and more importantly B) when you have "not working" code, then read [mcve] and add that code + error description to the question. – GhostCat Aug 31 '18 at 12:28

1 Answers1

0

Create java POJO class corresponding to your json object.

class TestPojo{
private List<String> schemas;
...
...
// and Getter & Setters
}

Then Use Gson Class

TestPojo obj=new TestPojo(); //fill obj with required values
Gson gson=new Gson();
String jsonString= gson.toJson(obj); // jsonString will have JSON of class TestPojo
Tarun
  • 986
  • 6
  • 19