Remove Double Quote in JSON_Encode()

Remove double quote in json_encode()

If you add an underscore to your regex at the end it will do it.

$array_final = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9_]*)":/','$1:',$array_final);

I assume that's what that preg_replace is for anyway.

How to remove double quotes from json_encode in php?

Try this

$array_final = preg_replace('/"([a-zA-Z_]+[a-zA-Z0-9_]*)":/','$1:',json_encode($you-array));

Output

{event:"2019-03-06",event_title:"meeting",description:"meeting with xyz",s_date:"2019-03-04"} 

Remove double quotes from json_encode array

If Google wants it in that particular format, simply feed him :)

I supposed the json_encoded result stored in $json.

So, you can do this:

$json = str_replace('"','', (string) $json);

remove quote on echo json_encode();

Try trim in php

<?php 
$name = "Aman";
$str = json_encode($name);
echo trim($str, '"'); // output : Aman
?>

How to remove double quotes of json_encode array

You could try using function intval($move) to get the integer value, and then assign the value.

http://php.net/manual/en/function.intval.php

json_encode remove quotes from keys?

When I test this portion of code :

echo json_encode(array( 'foo' => 'bar'));
die;

I get :

{"foo":"bar"}

Which is valid JSON.

(Note these are double-quotes, and not simple-quotes as you posted)


The ouput you are asking for :

{ foo : 'bar' }

is valid Javascript, but is not valid JSON -- so json_encode will not return that.

See json.org for the specification of the JSON format -- which is a subset of Javascript, and not Javascript itself.


Instead of "stripping the quotes out myself with some ugly regex", you should adapt your code, so it accepts valid JSON : this is way better, in my opinion.

Remove double quotes from the Json_encode result

Try this:

For no values use floatval($var); Ref: http://php.net/manual/en/function.floatval.php

Current output:

{"series":[{"name":"Today","data":["123","123","123"]}], "y_axis":{"format":"percent"},"x_axis":{"labels":["00:00","00:00","00:00"]}}

Handle "123","123","123" using floatval($var);
and ["00:00","00:00","00:00"] will come in double quotes as its strings.



Related Topics



Leave a reply



Submit