I can't read my JSON

Hello everyone, this is my first post, I thank the community in advance for your help.

I would like to read my JSON in order to retrieve the data and be able to display them on my application, however I have the feeling that my JSON is not a JSON.

here is my console error : {error: SyntaxError: Unexpected token ( in JSON at position 0 at JSON.parse (<anonymous>) at XMLHtt…

And I realized that my JSON started with a ‘(’ like this:

([
    {
        "CLI_ID": "4",
        "0": "4",
        "CLI_NOM": "La Casa de Las tapas",
        "1": "La Casa de Las tapas",
        "CLI_ADRESSE": "49 Rue Molière",
        "2": "49 Rue Molière",
        "CLI_LAT": "49.4384879",
        "3": "49.4384879",
        "CLI_LNG": "1.0987107",
        "4": "1.0987107",
        "CLI_VILLE": "Rouen",
        "5": "Rouen",
        "CLI_CP": "76000",
        "6": "76000",
        "CREATED_AT": "2019-05-02 13:02:56",
        "7": "2019-05-02 13:02:56",
        "UPDATE_AT": "2019-05-02 00:00:00",
        "8": "2019-05-02 00:00:00",
        "CLI_DESCRIPTION": "Restaurant de tapas, bar à vins et cocktails.",
        "9": "Restaurant de tapas, bar à vins et cocktails.",
        "CLI_CATEGORIE": "Restaurant de tapas",
        "10": "Restaurant de tapas"
    }
]);

How could I remove these ‘(’?
My JSON is generated in php, you can test the API via postman at this address:
https://api.snoopdoggybag.fr/Clients/selectAllByNom

Thanks all !

The response from your API service are ok.
Upload your app code where you call to this service

1 Like

The ( at the beginning of the JSON is illegal, as the error message says: error at line 0

as well as the ) at the end and the ;

JSON is pretty strict. Otherwise use an online JSON validator tool???

https://jsonlint.com/ etc

problem solved, it came from my php code -
It was enough to remove the parentheses of this code:
echo $ _GET ['jsoncallback']. '('. json_encode ($ datas). ');';

(I was not at the origin of this code) :yum: