Remove Quote from the Jsonarray Output

Remove quote from the JSONArray output

1. .replaceAll()

testValue.toString().replaceAll("\"", "");

This method replace all the double quotes which are present in your name not the first and the last.

Example : "Abcd" becomes Abcd but if the name is "Ab"cd" it should be Ab"cd according to your requirement but it becomes Abcd. Mean to say that all the double quote replaced.

2. substring()

If you want to use the substring method approach then use the following syntax to remove the first and the last double quotes from your string:


1 - indicates the first character of the string

testValue.toString().length()-1 : indicates the last character of the string.

For your case .substring() method is more better than the .replaceAll(), if .getString() not working.

3. .ValueOf() OR .getString()

Don't know In your case why it is not working ? (may be because the string itself containing the quotes) other wise the best way is to Convert the JSONValue to the String as String.ValueOf(testValue);



Otherwise give preference as : 3 > 2 > 1

Remove all the Quotes from JSONArray

I see whats wrong. You are not printing the result from replaceAll call. To remove all quotes from json array output, try this.

JSONArray error = data.getJSONArray("error");
System.out.println(error.toString().replaceAll("\"", " "));

Please note, this will also remove any quotes inside array values, which might not be what you want. For example, the output of ["cool says \"meow\"","stuff"] would be [ cool says \ meow\ , stuff ]. If you only want the string values, I recommend looking at the org.json.JSONArray docs for JSONArray::get(int) and JSONArray::length()

How to remove double quotes from JSON Array

Try this:

let objectArray =>{return JSON.parse(each)});
console.log(objectArray) // This will give you the required output

Is there a way to remove quotes from the output of a data frame entered into the toJSON function in R?

One possible way using regex, removing quotes from values appearing before colon :

json_string <- jsonlite::toJSON(data, dataframe="rows")

temp <- stringr::str_replace_all(json_string, '"(\\w+)"\\s*:', '\\1:')

write(temp, "output.txt")

Remove First and Last Double Quote From JSON Array

You're creating strings as the first element of an array instead of an array of elements. You'll still have to contend with quotes because some of your data are strings - there's no getting round that - but this is closer to what you want.

const results = [
{ id: 1, name: 'Andy', lastname: 'Jones', address: '999 Letsbe Avenue', status: 5, about: 'About' },
{ id: 2, name: 'Sue', lastname: 'Barlow', address: '1 Fifth Street', status: 1, about: 'Another about' }

const storeArray = [];

for (let i = 0; i < results.length; i++) {




Related Topics

Leave a reply