0

I have successfully produced the json representation below for one custom object. However, when I use json_decode(jsonObjectBelow) I am not successfully in converting it to an array. I have finally found out why this has happened. If I delete characters with accents e.g "Muñoz-Gómez", then the json_decode(jsonObjectBelow) works, and I am able to generate my array and extract the attributes. For practical purposes, I cannot scour all the attributes and removing these accents...Is there a solution?

json_object received: [{"abstractText":"Fevers of unknown origin (FUOs) may be due to any of over 200 different disorders. We present a most unusual case of an FUO in a returning traveler from the Dominican Republic. Work-up for Q fever, Brucellosis, Bartonella, malaria and HIV were negative, but very highly elevated ESRs and ferritin levels suggested possible Legionnaire\u0027s disease. This is the third reported case of Legionnaire\u0027s disease presenting as an FUO.","authorString":"Muñoz-Gómez S, Cunha BA.","issue":"1","journalTitle":"Heart Lung","pageInfo":"72-74","pmid":"25444558","pubYear":"2015","title":"Fever of unknown origin (FUO) due to Legionnaire\u0027s disease.","volume":"44"}]

This code works for text in attributes that have not got accents, but does not work for text with accents. My php code:

     //Get JSON POST
       $json = $_POST["jsonObj"];

     //Decode JSON into an Array
      $data = json_decode($json);

     for($i = 0; $i<count($data); $i++){

     echo "[".$i."]" . " " .$data[$i]->authorString . "/  " . $data[$i]->journalTitle . "<br>";
     }
1

1 Answer 1

0

if possible try to encode the values and the send the json object. Try the steps in the following link:

UTF-8 character encoding battles json_encode()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.