Json in format without quotes

1

Hello, I'm consuming data from a webservice where I generate a json by PHP's json_encode.

    require_once('../lib/nusoap.php');

    $client = new nusoap_client('http://dominio.com.br/webservice/ws?wsdl', true);

    $result = $client->call('getUnidades');
    header('Access-Control-Allow-Origin: *');
    header( 'Content-Type: application/json' );
    echo(json_encode($result));

In the development environment I have this result:

[{"valor":"brasilia","legenda":"Bras\u00edlia (DF)"},{"valor":"osasconew","legenda":"Osasco (SP)"}]

But in the production environment that Locaweb looks like this:

[{valor:brasilia,legenda:Bras\u00edlia (DF)},{valor:osasconew,legenda:Osasco (SP)}]

It is without quotation marks and with this it is giving syntax error in javascript SyntaxError: JSON.parse: expected property name or '}

The javascript function looks like this:

    showUnits: function(){
    $.ajax({ 
        dataType: "json",
        url:"webservices/get-unidades.php",
        success: function(data){
            jason = $.parseJSON(data);

            $.each(jason, function(i, item){
                $('#slcUnidade').append('<option value="'+ item.valor +'">'+ item.legenda +'</option>');
            });
        },
        error: function(){
            $('#slcUnidade').append('<option>Não há unidades diponíveis</option>');
        }
    });
}

I would like help solving this json problem without quotes in Locaweb.

Thank you.

    
asked by anonymous 07.07.2017 / 03:25

0 answers