How To Create A JSON Request With More Than One Array Element?

How To Create A JSON Request With More Than One Array Element?

Hi,

I am using the postURL functionality. JSON Request body contains more than one array element like shown below,

Original JSON Request Body Format To Be Used:

{
  "Name": "Hello World",
  "Roles": [
   
{
     
"Profile": "asdf",
    }
 
],
 
"Description": "sent"
}

This is my code used for creating above JSON request using "map()" functionality,

  myMapData = map();
  myMapData.put("Name", "Hello World");
  myMapData.put("Description", "sent");

//  I used the following code for creating "Roles" array element which i referenced from a blog listed below


// Code For "Roles"

   start_list = List(); 
    start_list = {"node1"};
    end_list = List();
    for each r in start_list
    {
            myMapTemplateRoles = map();
            myMapTemplateRoles.put("Profile","asdf");
            stringMap = myMapTemplateRoles;
            end_list.add(stringMap.toString());
    }

// End Of Code For Roles

myMapData.put("Roles", end_list);

// End Of Code

JSON Request Body Format Obtained using above code:

{
  "Name": "Hello World",
  "Roles": 
   "[
   
{
     
"Profile": "asdf",
    }
    ]"
 
,
 
"Description": "sent"
}
The above "obtained JSON Format" is displayed as Invalid when tested with 
websie below,
http://jsonlint.com/
When i pass the above "obtained JSON Format" through postUrl,i am getting 
an error "Bad JSON Request". I think extra quotation marks(hi lighted)before and 
after square brackets of "Roles" in JSON Request is creating this error.
I have followed the same steps for creating a map variable then why 
i am getting an invalid JSON Format string while creating through map(). 
Please let me know if there is any problem in my code.





                  Zoho Marketing Automation

                    Zoho SalesIQ Resources



                          Manage your brands on social media

                            Zoho Pagesense Resources



                                  Zoho TeamInbox Resources

                                    Zoho DataPrep Resources



                                      Zoho CRM Plus Resources

                                        Zoho Books Resources


                                          Zoho Subscriptions Resources

                                            Zoho Desk Resources

                                              Zoho Projects Resources


                                                Zoho Sprints Resources


                                                  Qntrl Resources


                                                    Zoho Creator Resources


                                                      Zoho WorkDrive Resources



                                                        Zoho Campaigns Resources

                                                          Zoho CRM Resources

                                                          • CRM Community Learning Series

                                                            CRM Community Learning Series


                                                          • Tips

                                                            Tips


                                                          • Functions

                                                            Functions


                                                          • Meetups

                                                            Meetups


                                                          • Kbase

                                                            Kbase


                                                          • Resources

                                                            Resources


                                                          • Digest

                                                            Digest


                                                          • CRM Marketplace

                                                            CRM Marketplace


                                                          • MVP Corner

                                                            MVP Corner


                                                          • Word of the Day

                                                            Word of the Day

                                                                Design. Discuss. Deliver.

                                                                Create visually engaging stories with Zoho Show.

                                                                Get Started Now