# Getting JSON Array in a Single Line

**URL:** <https://forum.uipath.com/t/getting-json-array-in-a-single-line/762301>\
**Category:** Off-Topic Discussions\
**Tags:** jsonarray, json-obj, json\
**Created:** [August 26, 2024, 7:02am UTC](https://forum.uipath.com/t/getting-json-array-in-a-single-line/762301 "2024-08-26T07:02:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raunak\_Bhanarkar](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/raunak_bhanarkar/32/496750_2.png) [@Raunak\_Bhanarkar](https://forum.uipath.com/u/Raunak_Bhanarkar)\
**Post date:** [August 26, 2024, 7:02am UTC](https://forum.uipath.com/t/getting-json-array-in-a-single-line/762301/1 "2024-08-26T07:02:38Z")

</div>

Hey, Im trying to get a response here of JSON array in a single line but it is giving in multi line array. Can someone help me with it?

The is the response im getting  
{  
“id\_success”: true,  
“user\_id”: “”,  
“email”: “”,  
“roll\_number”: “”,  
“numbers”: ,  
“alphabets”: [  
“A”,  
“C”,  
“Z”,  
“c”,  
“i”  
],  
“highest\_lowercase\_alphabet”: “i”  
}

This is the response I want

{  
“id\_success”: true,  
“user\_id”: “”,  
“email”: “”,  
“roll\_number”: “”,  
“numbers”: ,  
“alphabets”: [“A”,“C”,“Z”,“c”,“i”],  
“highest\_lowercase\_alphabet”: “i”  
}

This is a post request , Im sending this data to the request

{  
“data”: [“A”, “C”, “Z”, “c”, “i”]  
}

This is my backend code

```auto
export async function POST(request: Request) {
  const requestBody = await request.json();

  const iterableArray: string[] = requestBody.data ?? [];

  const numsArray: number[] = [];
  const letterArray: string[] = [];
  let highestLowercaseLetter = '';

  iterableArray.forEach((item: string) => {
    if (!isNaN(Number(item)) && item.trim() !== '') {
      numsArray.push(Number(item));
    }

    if (/^[A-Z]$/.test(item) || /^[a-z]$/.test(item)) {
      letterArray.push(item);

      if (/^[a-z]$/.test(item)) {
        if (highestLowercaseLetter === '' || item > highestLowercaseLetter) {
          highestLowercaseLetter = item;
        }
      }
    }
  });

  const responseJson = {
    id_success: true,
    user_id: "",
    email: "",
    roll_number: "",
    numbers: numsArray,
    alphabets: letterArray,
    highest_lowercase_alphabet: highestLowercaseLetter
  };

  // Remove the formatting argument to get the array in a single line
  const responseJsonFormat = JSON.stringify(responseJson);

  return new NextResponse(responseJsonFormat, {
    status: 200,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

```

---

<div class="post-metadata">

**Author:** ![J0ska](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/j0ska/32/111328_2.png) [@J0ska](https://forum.uipath.com/u/J0ska)\
**Post date:** [August 26, 2024, 10:26am UTC](https://forum.uipath.com/t/getting-json-array-in-a-single-line/762301/2 "2024-08-26T10:26:19Z")

</div>

Both variants are valid JSON format.  
Any particular reason why the array should be in single line?

Cheers
