'Nested List into JSON File

Am still a complete beginner at programming and have now been given the task of converting with JavaScript an object in Nested List format, which I get given as a string, into a json file.

Nested List looks like this:

 ( OBJECT  objectname
         () objecttype
         (
            (
               ( "2021-01-01-01:00"  "2021-01-01-01:16:40"  TRUE  TRUE ) //time lapse
               (
                  (
                     (
                        ( 87  63  41  35 )
                        ( 91  71  41  35 )
                        ( 87  63 21  33 )))))))

It may be that several time lapses are listed, or several groups of coordinates are available within a time period.

For example like this

(OBJECT  objectname
() objecttype
(
    (
        ("2021-01-21-01:00"  "2021-01-21-08:00"  TRUE  FALSE)
        (
            (
                (
                    (0 - 1  360.0  3
                    (4 - 0.9  99 16)))))
    (
        ("2021-01-21-08:00"  "2021-01-21-09:00"  TRUE  FALSE)
        (
            (
                (
                    (47  84 1  9)
                    (2 95  2  9)
                    (24  95  17  9)))))))

or like this

 (OBJECT  objectname
() objecttype
(
    (
        ("2021-01-01-01:00"  "2021-01-01-01:00:02"  TRUE  TRUE)
        (
            (
                (
                    (7 42  5  38)
                    (7 41  5  38)))
            (
                (
                    (8 37  7  22)
                    (8 34  7  22)))))))

The desired format should look something like this:

{
"objectname" : "//name", 
"objecttype" : "//type",
"obj_overall" : [
     "start" :  "2021-01-02-00:00:00",
     "end" : "2021-01-03-00:00:00",
     "beg_incl" : "TRUE",
     "end_incl" : "FALSE",
     "coordinates" :[ 
         {  "x1" : "0",
            "y1" : "0",
            "x2" : "0",
            "y2" : "0" },
         {  "x1" : "0",
            "y1" : "100",
            "x2" : "0",
            "y2" : "50"} ],
{// next time lapse..}]
} 

So my question now would be how to best proceed here and read the desired parts out of the string so that you can parse it into the json format.

Can anybody help me? Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source