Use json objects. Do something like that. Don't write json by hand, you could easily do a mistake.

public JSON() throws JSONException
{
    JSONArray locArr=new JSONArray();
    locArr.put(createLatLng(40.900799, 8.606102));
    locArr.put(createLatLng(42.900799, 9.606102));
    JSONObject main=new JSONObject();
    main.put("locations", locArr);
    Log.d("JSON",main.toString());      
}


public JSONObject createLatLng(double lat, double lng) throws JSONException
{
    JSONObject latLng=new JSONObject();
    latLng.put("lat",lat);
    latLng.put("lon",lng);
    JSONObject latLngWrap=new JSONObject();
    latLngWrap.put("latLng",latLng);
    return latLngWrap;
}
Answer from maciekczwa on Stack Overflow
Discussions

Adding Json Body to a HTTP request
Hi Need to add the below request to a HTTP Request. However I cant workout how to escape the double quotes, I’ve tried using “”" but it doesn’t seem to be accepted by the editor Code I want { “type”: “select”, “whe… More on forum.uipath.com
🌐 forum.uipath.com
18
2
March 23, 2021
How to pass values (parameters) into a JSON request body for a POST API | OutSystems
How to pass values (parameters) into a JSON request body for a POST API More on outsystems.com
🌐 outsystems.com
Creating a request with raw json body
I am trying to create a request inside a new/update collection API call, having the equivalent of the raw - json body inside the client. Right now, it seems like I need to send something like (I am using ruby, but it shouldn’t make a big different): body: { mode: 'raw', json: { field1: 'value', ... More on community.postman.com
🌐 community.postman.com
4
0
July 1, 2021
apex - Add JSON string in JSON body - Salesforce Stack Exchange
Is there a way I can pass JSON string in the JSON body. More on salesforce.stackexchange.com
🌐 salesforce.stackexchange.com
🌐
JSON
json.org › example.html
JSON Example
This page shows examples of messages formatted using JSON (JavaScript Object Notation).
🌐
mabl help
help.mabl.com › hc › en-us › articles › 19078205331348-JSON-structure-and-syntax
JSON structure and syntax – mabl help
4 weeks ago - A JSON object contains one or more ... with curly braces { }. For example, an API call that authenticates a user may return the following response body to indicate that a user is logged in:...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Request › json
Request: json() method - Web APIs | MDN
November 7, 2025 - The request body cannot be parsed as JSON. ... const obj = { hello: "world" }; const request = new Request("/myEndpoint", { method: "POST", body: JSON.stringify(obj), }); request.json().then((data) => { // do something with the data sent in the request });
🌐
Informatica
docs.informatica.com › reference material › rest api reference › informatica intelligent cloud services rest api › header and body configuration › json format example
JSON format example
You can then use the sessionId and the baseapiUrl to construct a request to obtain your organization's license information, for example: GET https://https://usw3.dm-us.informaticacloud.com/saas/public/core/v3/license/org/52ZSTB0IDK6dXxaEQLUaQu Content-Type: application/json Accept: application/json INFA-SESSION-ID: 9KA11tLGqxVcGeul8SQBK3 · Header and body configuration ·
🌐
Baeldung
baeldung.com › home › web › sending json http request body in terminal
Sending JSON HTTP Request Body in Terminal | Baeldung on Linux
March 18, 2024 - In this tutorial, we’ll be learning how to send JSON objects as the request body correctly with the help of the Content-Type HTTP header. In Linux, curl and wget are the common terminal-based HTTP clients. Given its popularity in the Linux ecosystem, we’ll be using them in this article for demonstration purposes. To obtain curl and wget, we can install them using the package manager. For example...
Find elsewhere
🌐
Atlassian
developer.atlassian.com › server › crowd › json-requests-and-responses
JSON requests and responses
These samples show the JSON representations that the Crowd REST Resources expect to receive. ... { "name" : "my_username", "first-name" : "My", "last-name" : "Username", "display-name" : "My Username", "email" : "user@example.test", "password" : { "value" : "my_password" }, "active" : true }
🌐
Practical Go Lessons
practical-go-lessons.com › post › go-how-to-send-post-http-requests-with-a-json-body-cbhvuqa220ds70kp2lkg
Go: How to send POST HTTP requests with a JSON body| Practical Go Lessons
Suppose you want to run this request: POST https://example.com/teacher. With the following JSON body: { "id": "42", "firstname": "John", "lastname": "Doe" } The first step is to build the body.
🌐
ReqBin
reqbin.com › req › 4rwevrqh › post-json-example
How do I post JSON to the server?
January 16, 2023 - The Content-Type request header specifies the media type for the resource in the body. Additionally, you can pass an "Accept: application/json" header, which tells the server that the client is expecting JSON data. In this POST JSON example, we send JSON data to the ReqBin echo URL with the ...
🌐
Medium
medium.com › @guptadiksha88 › best-practices-for-handling-json-request-bodies-in-post-api-calls-1b19fc6a8da7
“Best Practices for Handling JSON Request Bodies in POST API Calls” | by Diksha Gupta | Medium
May 24, 2023 - Common content types include “application/x-www-form-urlencoded” for form data and “application/json” for JSON data. The server, upon receiving the POST request, processes the data. Once the server has processed the request, it sends an HTTP response back to the client, indicating the status of the operation. Now let’s discuss one POST request as shown below ... Here, through this request, we want to create a new placeholder resource on the server by providing all the required values in the request body.On the server side, the new resource will be created with all the provided information and a response will be sent back to the client.
🌐
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
...as description and tax are optional (with a default value of None), this JSON "object" would also be valid: ... from fastapi import FastAPI from pydantic import BaseModel class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None app = FastAPI() @app.post("/items/") async def create_item(item: Item): return item · ...and declare its type as the model you created, Item. With just that Python type declaration, FastAPI will: Read the body of the request as JSON.
🌐
Postman
community.postman.com › help hub
Creating a request with raw json body - Help Hub - Postman Community
July 1, 2021 - I am trying to create a request inside a new/update collection API call, having the equivalent of the raw - json body inside the client. Right now, it seems like I need to send something like (I am using ruby, but it shouldn’t make a big different): body: { mode: 'raw', json: { field1: 'value', field2: 'value2' } } I want to avoid using 'formdata', because I already have the hash and parsing it into formdata format would add extra complexity (especially because I have to handle ...
🌐
Retool
community.retool.com › 💬 queries and resources
API REST POST Request body in JSON is treated as string - 💬 Queries and Resources - Retool Forum
March 8, 2024 - I've been trying to setup a POST request in my REST API; however I'm having an issue with the body I send on the request; the body contains a nested object, but the payload is always sent as a string; I've followed the s…
🌐
Apidog
apidog.com › articles › postman-send-json
How to Send JSON Data in Postman
April 23, 2024 - So, how do you send JSON using Postman? The following section provides a detailed Postman POST request body JSON example.
🌐
EasyMorph Community
community.easymorph.com › t › post-request-with-nested-json-body-how-can-i-generate-it › 2933
POST Request with nested JSON Body - how can I generate it? - EasyMorph Community - Data preparation professionals and enthusiasts
July 30, 2021 - Hello, I'm trying to send data through a JSON Body, however I think that the API receiving the data is expecting a nested JSON, with the text "inputs" in the first level, and the inputs themselves in the second level: More details: https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_custom_notification.htm So in EasyMorph, I created the following action: However, here I can't include the first JSON level ("inputs"). At the moment this is an "Iterate...