Is throwing malicious strings in json_encode a good way to evade Stored XSS?

I’m aware that filtering strings doesn’t go this way, but when encoding xss payloads into json format in php and storing that information temporary in classes, the result in the browser, it will show all the strings that are before the javascript content, the payload in the middle won’t execute since i use json_encode for all the strings and all what is after the javascript content is not displayed in the browser. but can i use this in real world applications?

Here is the generated content after the submit

enter image description here

I use a picture to read with more comfortability