Invalid Json response with API CURL PHP - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, May 31, 2021

Invalid Json response with API CURL PHP

I am trying to call an API using CURL , and the supplier is only allowed x-www-form-urlencoded's content-type, but it responds XML with JSON within it.

However, in PHP's curl response, it will remove all xml tag. This is the respond I got :

{ "Description":"MERCEDES BENZ C 300 AMG LINE MY17 W205 FACELIFT 9 SP AUTOMATIC 9G TRONIC", "RegistrationYear":"2020", "CarMake":{ "CurrentTextValue":"MERCEDES BENZ" }, "CarModel":{ "CurrentTextValue":"C" }, "MakeDescription":{ "CurrentTextValue":"MERCEDES BENZ" }, "ModelDescription":{ "CurrentTextValue":"C" }, "Seats":"5", "Body":"SEDAN", } The registered car is a MERCEDES BENZ C 300 AMG

The problem is at last "sentence" where it is not a valid json string, is there any way to remove unwanted "sentence" after the last } i.e. the "The registered car is a MERCEDES BENZ C 300 AMG"

any idea???



source https://stackoverflow.com/questions/67766503/invalid-json-response-with-api-curl-php

No comments:

Post a Comment