Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

Someone on quora asked:

Is it bad to use Regex to sift through JSON data?

Well, you probably know the famous quote:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems. - Jamie Zawisnki

That being said, regular expressions can be a good approach for particular problems. Sifting through JSON however, does not sound like one of them. Why not? JSON is already a structured format that has elements you can easily iterate through using normal programming constructs. I’m assuming you mean using regular expressions to search through JSON data by treating the entire JSON object as a string. If instead you’re using regex matching on individual JSON elements, that’s probably fine.

Posted by under notes at #answers
Also on: quora / 0