INNOV-AI

Innovation and Research from Réunion Island, France

Back   Home

Parse a JSON array from remote connection @ CONNECT - Connections @ MentDB Weak

> Start the server
> (or start the server for the first time (embedded mode - H2 Database))
> (or start the server for the first time (remote mode - MySQL 8 Database))
> Open the MentDB Weak Editor

Click on 'CONNECT' tab, open 'Remote file', right click on 'demo_cm_file' and select 'GEN > PARSE JSON ARRAY'

MQL INPUT
script create post "demo.file.json.array.parse" false 1 
  (param
  	(var "[fileName]" {true} "The file name" is_null:false is_empty:false "test.json")
  ;) 
  "Parse a JSON Array" 
{

	#Initialization;
	-> "[targetPath]" "/";

	#Load the connection id;
	json load "cm" (cm get "demo_cm_file");
	-> "[localDir]" (json select "cm" /localDir);

	#Load the file;
	json load "jsonId1" (file load (concat [localDir] "/" [fileName]));

	-> "[nb]" (json count "jsonId1" [targetPath]);
	
	#Parse the tab;
	for (-> "[i]" 0) (< [i] [nb]) (++ "[i]") {

		#Get value;
		-> "[to_use]" (json select "jsonId1" (concat (if (string ends_with [targetPath] "/") {[targetPath]} {concat [targetPath] "/";}) "[" [i] "]"));

		#Your action here ...;
		log trace (concat "[to_use]=" [to_use]);

		
	
	};
	
} "Return nothing";
start: 2026-01-17   end: 2026-01-31   v_start: 401   v_end: