In my application i store my date in a localStorage variable called "postResult"
localStorage.setItem("postResult", JSON.stringify(result));
In next step i store the data in a PHP variable.
$posts = "<script>document.write(localStorage.getItem('easyscanResult'))</script>";
When i output the result i can see a object string. Here is a small excerpt of my data:
{"posts":"20","findings":[{"title":"test title","category":"healthy","data":{"id":314,"date":"2023-02-21T10:53:01.268Z","slug":"test-title","name":"Test title","description":"Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet sequi at cupiditate delectus quis commodi reiciendis obcaecati a eligendi, unde consequuntur? Repellat eos accusantium voluptatum expedita cumque doloribus dolorem libero?
I want to translate the data in an PHP Object
<?php $posts = json_decode($posts); ?>
But now the result is null
and i have no idea why?
I tried the string already in an Online Converter. I have no problems so the syntax is fine.
What have i'm forgotten?
Edit: The $posts returns a string not an object. I want to translate the string into a PHP object. This not work for me.