Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl JSON validation function

Tags:

json

perl

debian

I'm using the Perl module, JSON when handling JSON data in a perl script.

I was looking to use valid_json from the JSON::Parser module, however it looks as though the version i'm using, 2.53 has deprecated this. Reading the docs for 2.53, i cannot see any validation functions.

Am i just to rely on decode_json, & encode_json returns to tell me that a JSON string is invalid?

like image 885
Simon. Avatar asked Oct 30 '25 00:10

Simon.


1 Answers

You may decode_json in eval and see if it will throw an exception.

like image 99
Alexandr Evstigneev Avatar answered Nov 01 '25 17:11

Alexandr Evstigneev