Use certain parts of a JSON file in PHP

-1

I have a considerably big doubt and I have no idea where to start.

The problem is that after passing the Cloud Vision OCR from Google to the document seen in the photo (although without the red boxes) I get a JSON file, which I will attach to a link because it has more than 130,000 lines. That JSON file must be used by a PHP to get all the text contained in the red boxes returned. I have thought about using json_decode in PHP and thus have the JSON file inside PHP, but I do not even know how to use it correctly. As expected, the scanned documents will be different and the texts will change relatively but the format will be exactly the same, the only thing that would have to be extracted would always be the bold titles of the sections.

Here I leave you in Dropbox the JSON file that produces the OCR

Any kind of contribution would be of great help to me, I am totally stuck for now.

Thank you in advance to everyone!

    
asked by Frampe 17.12.2018 в 21:22
source

1 answer

0

With respect to getting the text, you will need to use json_decode to access the field that has the text.

$json = {...AQUI TU ARCHIVO...};
$decoded = json_decode($json);
$texto = $decoded->fullTextAnnotation->text;

In the variable $texto you can find the text that you will have to parsed to get the information you want, maybe you should open another question, because I do not know if Cloud Vision can keep the information of the style that it seems is how the text is defined of interest.

    
answered by 17.12.2018 в 22:12