'12/02/2025
'2d array to JSON
'
dim int ar[10,10]
int x,y
'
'DATA
'
for y=1 to 10
  for x=1 to 10
    ar[y,x]=x-11+y*10
  next
next
'
'JSON FORMAT 2D ARRAY
'
uses console
int le
string s
int i=1
string buf=nuls 100000 '100k
'
def append
  le=len  s
  mid buf,i,s
  i+=le
end def
'
s="{"+cr+"  "+qu+"array"+qu+":["+cr
append
for y=1 to 10
  s="    [ "
  append
  for x=1 to 10
    s=str(ar[y,x])
    if x<10
      s+=","
    endif
    append
  next
  s="  ]"+cr
  append
next
s=cr+"  ]"+cr+"}"+cr
append
'
buf=left buf, i-1
print buf
wait(10000)
