1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/you-can-check-if-a-string-contains-json-by-decoding-it-encoding-it-again-and-comparing-the-value-with-the-original.md
2021-10-29 20:50:56 +02:00

12 lines
No EOL
586 B
Markdown

---
title: 'You can check if a string contains JSON by decoding it, encoding it again, and comparing the value with the original'
tweet_id: '1454133800888410119'
thread_slug: weekly-thread-2021-43
author_username: freekmurze
images:
- 'https://pbs.twimg.com/media/FC4Bs0lXEA4WV-P.jpg'
created_at: 2021-10-29T17:11:29+00:00
slug: you-can-check-if-a-string-contains-json-by-decoding-it-encoding-it-again-and-comparing-the-value-with-the-original
---
🔥 A way to check if a string contains valid JSON: just decode it, encode it again, and check if it matches the original value
#php