I am writing a Java application where I have to extract information from a JSON file. I want to get every element of a JSON array using Regex. I found this expression \[([^]]+)\]
which works only with non-nested arrays, but not for the example below.
list[
0{
somedata{...},
sublist0[
somedata(...),
somedata(...)
],
key: value,
},
1{
somedata{...},
sublist1[
somedata(...),
somedata(...)
],
key: value,
}, .... ,
N{
somedata{...},
sublistN[
somedata(...),
somedata(...)
],
key: value,
}
],
somedata{...}
For this example, the expression matches element 0, sublist1, sublist2 ... sublistN and ignores the other elements from the elements. I am looking for the appropriate regular expression because I can't use any external libraries for this project. The elements' names may also vary.