I have a string object stored in a variable passed from another class. My question is how can I add a comma between two objects, excluding the last object? Below is my code snippet:
{
"id":"57e4d12e53a5a",
"body":"asdas",
"published":"Fri,
23 Sep 2016 06:52:30 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,"height":48
}
}
},
{
"id":"57e4d51165d97",
"body":"jackiechanSADAS",
"published":"Fri, 23 Sep 2016 07:09:05 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,
"height":48
}
}
},
{
"id":"asas",
"body":"peterting",
"published":"Fri, 23 Sep 2016 07:09:05 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,
"height":48
}
}
}
My challenge is how to programmatically add a comma "," between each object, excluding the last one. Since the entire content is stored as a string, I need the comma for proper parsing into an object.