From 7b6175582e1db3d4dc2c6e543f06bc5fd4422697 Mon Sep 17 00:00:00 2001 From: Monte Goulding Date: Wed, 15 Mar 2017 15:55:20 +1100 Subject: [PATCH] Fix element encoding This patch ensures that all array elements are textEncoded correctly. --- mergJSON/mergJSONLibrary.livecodescript | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mergJSON/mergJSONLibrary.livecodescript b/mergJSON/mergJSONLibrary.livecodescript index 6e7cc85..cd3c1a9 100644 --- a/mergJSON/mergJSONLibrary.livecodescript +++ b/mergJSON/mergJSONLibrary.livecodescript @@ -59,12 +59,21 @@ key -> value pairs. */ function JSONToArray pJSON - local tArray,tKeys - repeat for each line tKey in mergJSONDecode(pJSON,"tArray") - put JSONToArray(tArray[tKey]) into tArray[tKey] - end repeat + local tArray,tRecurse, tKeys + put mergJSONDecode(pJSON,"tArray") into tRecurse if tArray is an array then + put the keys of tArray into tKeys + + split tRecurse by return as set + repeat for each line tKey in tKeys + if tRecurse[tKey] then + put JSONToArray(tArray[tKey]) into tArray[tKey] + else + put textDecode(tArray[tKey],"UTF8") into tArray[tKey] + end if + end repeat + return tArray else return textDecode(tArray,"UTF8")