smarter JSON detection