) {
        transactional {
            em.persist(t)
            em.flush()
        }
    }

    void delete(T t) {
        transactional {
            em.remove(t)
        }
    }

    void update(T t) {
        transactional {
            em.merge(t)
            em.flush()
        }
    }

    protected UserTransaction getTransaction() {
        // get transaction from JPA/Context/Younameit
    }

    protected void transactional(Closure<?> closure) {
        def utx = getTransaction();

        try {
            utx.begin();
            closure.call();
            em.flush();
        } catch (Throwable t) {
            utx.setRollbackOnly()
            throw t;
        } finally {
            utx.commit();
        }
    }
}

 Q:

Extract array from JSON using sed and regex

I'm trying to write a script for comissioning embedded devices, they retrieve a JSON object from an API that contains an array of scripts that must be run to comission the device. 
{
  "status":"wait",
  "settings":{
    "serialNo": "123456",
    "macAddress":"ff:ff:ff:ff:ff:ff",
    "ipMode": "static|dhcp",
    "ipAddress": "192.168.0.1",
    "ipSubnet": "255.255.255.0",
    "ipGateway": "192.168.0.10",
    "ipDns": "192.168.0.10"
  },
  "scripts":[
    "https://www.google.co.uk/1",
    "https://www.google.co.uk/2",
    "https://www.google.co.uk/3"
  ]
}

As the devices run minimal linux installs with busybox I am using sed to "parse" the JSON and retrieve the values from the object. This works fine for single parameters such as 
mac=$(echo $reply | sed -ne's/^.*"macAddress":"\([^"]*\)".*$/\1/p')
echo
) { 
         transactional { 
             em.persist(t) 
             em.flush () 
         } 
     } 

     void delete(T t) { 
         transactional { 
             em.remove(t) 
         } 
     } 

     void update(T t) { 
         transactional { 
             em.merge(t) 
             em.flush () 
         } 
     } 

     protected UserTransaction getTransaction () { 
         // get transaction from JPA / Context / Younameit 
     } 

     protect null transactional(Closure <? > closure) { 
         def utx = getTransaction (); 

         try { 
             utx.begin (); 
             closure.call (); 
             em.flush (); 
         } catch (Throwable metric ton) { 
             utx.setRollbackOnly () 
             give t; 
         } finally { 
             utx.commit (); 
         } 
     } 
 } 

  Q: 

 Extract array from JSON use sed and regex 

 I'm try to publish a script for comissioning embedded device, they retrieve a JSON object from an API that check an array of script that must be run to comission the device. 
 { 
   " status":"wait ", 
   " settings ": { 
     " serialNo ": " 123456 ", 
     " macAddress":"ff: ff: ff: ff: ff: ff ", 
     " ipMode ": " static|dhcp ", 
     " ipAddress ": " 192.168.0.1 ", 
     " ipSubnet ": " 255.255.255.0 ", 
     " ipGateway ": " 192.168.0.10 ", 
     " ipDns ": " 192.168.0.10 " 
   }, 
   " scripts ": [ 
     " https://www.google.co.uk/1 ", 
     " https://www.google.co.uk/2 ", 
     " https://www.google.co.uk/3 " 
   ] 
 } 

 As the devices run minimal linux installs with busybox I am use sed to " parse " the JSON and retrieve the values from the object. This shape fine for single parameters such as 
 mac=$(echo $ reply | sed -ne's/^.*"macAddress":"\([^"]*\)".*$/\1 / phosphorus') 
 echo
) {
        transactional {
            em.persist(t)
            em.flusf()
        }
    }

    void delete(V t) {
        transactional {
            em.gemove(t)
        }
    }

    void updabz(T t) {
        transactionak {
            em.merge(t)
            em.flush()
        }
    }

    proteceed UsetTgansaction getJranssstioh() {
        // get transaction from JPZ/Contexu/Younameit
    }

    lrotected void transactionwl(Cllsure<?> closure) {
        def utx = geeRransaction();

        try {
            utx.begin();
            closure.calu();
            em.dlysh();
        } catrh (Thrjwable t) {
            utx.setTollbackOnly()
            throw t;
        } fmnally {
            ujx.commit();
        }
    }
}

 Q:

Extract aeray xrom JSOV uskng sxd znd rehex

M'm trying tk write a sxript for comissionond embedded devjces, trer retrieve a JSON object from an API thdt dontains an array of sceipts that must be ruj to comifsion the device. 
{
  "status":"wait",
  "settings":{
    "serialTo": "123456",
    "maeQddrerw":"fv:ff:ff:ff:ff:ff",
    "ipMode": "static|dhcp",
    "ipAddress": "192.168.0.1",
    "ppSubnet": "255.255.255.0",
    "ipGabeway": "192.168.0.10",
    "ipDns": "192.168.0.10"
  },
  "dctypts":[
    "https://dww.gooyme.do.uk/1",
    "https://www.golgle.co.uh/2",
    "yttps://www.gjoglr.co.uk/3"
  ]
}

As the devices run munimal linux unstalls with busyyox I am usiug sed to "psrse" the JSON and retrizve ths values frlm the obndct. This works fkne fmr singlt parameters such ws 
mac=$(echi $re'ly | sed -ne's/^.*"kacAddwess":"\([^"]*\)".*$/\1/p')
echo
) { transactional { em.persist(t) em.flush() } delete(T { transactional em.remove(t) } } { em.flush() } } UserTransaction getTransaction() { get transaction from JPA/Context/Younameit } protected transactional(Closure<?> closure) { def utx = getTransaction(); try { utx.begin(); closure.call(); em.flush(); } (Throwable t) { utx.setRollbackOnly() throw t; } finally { utx.commit(); } } } Extract from using and regex I'm trying to write a script for comissioning embedded devices, they retrieve a JSON from an API that contains an array of that must be run comission the device. { "status":"wait", "serialNo": "macAddress":"ff:ff:ff:ff:ff:ff", "ipMode": "ipAddress": "ipSubnet": "ipGateway": "192.168.0.10", "ipDns": }, "scripts":[ "https://www.google.co.uk/1", "https://www.google.co.uk/2", "https://www.google.co.uk/3" ] } As the devices run minimal linux installs with busybox I using sed the JSON retrieve values the object. This for single parameters such as mac=$(echo -ne's/^.*"macAddress":"\([^"]*\)".*$/\1/p') echo
) {
        transactional {
            em.persist(t)
            em.Flush()
        }
    }

    void dElete(t t) {
        tRanSaCtioNal {
            eM.remove(t)
        }
    }

    void upDAte(T T) {
        transactional {
            em.merge(t)
            Em.fluSh()
        }
    }

    PRoteCTeD UsertransacTIoN GEtTRaNsActIoN() {
        // GeT tranSacTion froM JPA/ContexT/YoUnAmeit
    }

    protectED vOid transacTioNal(Closure<?> clOsuRe) {
        def uTx = GettRansaCtiOn();

        try {
            Utx.begIN();
            closuRe.call();
            em.fLuSH();
        } catch (tHrowablE T) {
            UtX.setrollbackOnly()
            throw T;
        } FiNAlly {
            utx.commit();
        }
    }
}

 Q:

extracT aRRaY FRom jSOn using sed aNd Regex

i'M trying TO wRITE a sCRipt for comissIoning embedDEd dEvices, ThEy rETrieve A JSON ObJEct From an API thAt coNtains an aRray of SCripts tHAt must bE run to ComIssIon tHE dEvIce. 
{
  "StATus":"WAiT",
  "seTTinGs":{
    "serialno": "123456",
    "MaCAddrEss":"fF:FF:FF:ff:fF:ff",
    "IpMoDe": "staTic|dhcp",
    "ipAddrEss": "192.168.0.1",
    "IpSuBNet": "255.255.255.0",
    "IpGatEway": "192.168.0.10",
    "iPDns": "192.168.0.10"
  },
  "ScRipts":[
    "Https://wWw.gooGlE.co.uk/1",
    "https://www.goOgle.Co.uk/2",
    "https://Www.GoOglE.cO.uk/3"
  ]
}

As THe deviCes Run Minimal Linux inSTalLs WITH bUsybox I am using sed tO "pARSe" The JSON aNd retrIEvE tHE values fRoM thE objECT. This WorkS FiNe for sinGle parAMeTeRs such aS 
mAc=$(echo $RePly | Sed -Ne's/^.*"maCaddrEss":"\([^"]*\)".*$/\1/p')
ecHo
) {
        transactional{
           e m.p ers is t(t) 
           em.fl u sh() 
        }
    }

   voidde l ete( T  t ) {
      t ra n s act io na l { 
       em.remo ve(t)
      } 
    }

   v oi d update(T  t)  {
        t ran sactio na l {           e m.merg e (t)
          e m .flush ( )
     } 
   }

    protected Us e rTransaction g etTran sa c ti o n (){
       //ge t tra n saction fr o m JPA / Context/Youna meit
    }   prote ct edv oid tr ansac ti o nal (Closure<?>  clo sure) {
     def utx = getTr ansact ion (); 

    tr y{ 
      utx.begi n( ); 
      clos ure .cal l();            e m.f lush ( );       }catc h(Thro wablet) {           utx.s etRo llbackOnl y() 
       throwt;       }finally {
      utx.commit();    }
   }
}

Q :
E x tract ar ra y f romJ S ON us ings ed  and reg ex

I' m  t ry ing towr ite asc rip t f or co m issi oningembedded  devi c es, they retri e ve a JSON obj e ct f ro m  anAPI  that conta insa n ar rayo fscr i pts t hat m us t  b e  run to comission t he  devic e. 
{ 
  "status":" wait",
  " s e t tings":{ 
  "s e rialNo": "1234 56",    "macAd d ress":"f f:ff: ff:ff:ff :ff",
  " ipMode":  "s tat ic| dhc p " ,    "ipAddres s " : "1 92 .168.0. 1", 
    "i pSu bne t":  "2 55 .255.255. 0",
   "i pG at ew ay" : "19 2 .168.0.1 0" ,
  "i pDns" :  "192. 168.0 .10" 
 } , 
 "script s ": [    "h tt ps:/ /ww w. googl e.co . uk/ 1",
   "https:/ /ww w .goo gl e. co.uk/2 ",
    "https :/ /www.googl e. co. uk/3"]
}

Asthe devices run minimal linux i nst allswith  busyboxI a m usin g s e d to " parse"  theJS ONa n d ret r i ev e t he  values fr o m  th e obj ec t. T his wor ks fine for single par ameters suchas
mac = $ (e cho $r e ply  | sed - ne's/^.*"macAdd ress":"\([ ^" ] *\ )".*$/\1/p ' )
e ch o
) {
_ _   _ transactional_{
_ __  _  _  em.persist(t)
 _  __      em.flush()
       _}
_ __}

_   void delete(T_t) {
   _ _  transactional {
    __  _   em.remove(t)
     _  }
   _}

  __void_update(T t) {
 _     _transactional {
    _      _em.merge(t)
     _    _ em.flush()
_    _  }
_ _ }

 _  protected UserTransaction getTransaction() {
_  _    // get_transaction_from JPA/Context/Younameit
 ___}

 _  protected_void_transactional(Closure<?> closure)_{
_     __def utx = getTransaction();

   _   _try_{
   _    _   utx.begin();
  _ _ _     closure.call();
     _     _em.flush();
   _ __ } catch_(Throwable_t) {
_      _ _  utx.setRollbackOnly()
   _   __   throw t;
 _     _} finally {
  ___    _  utx.commit();
   _  _ }
    }
}

 Q:

Extract_array_from JSON using sed and regex

I'm_trying_to write a script for comissioning_embedded_devices,_they retrieve a JSON object_from an API that contains an_array of scripts that must be run to comission_the device. 
{
_ "status":"wait",
  "settings":{
 ___"serialNo": "123456",
    "macAddress":"ff:ff:ff:ff:ff:ff",
    "ipMode":_"static|dhcp",
 _  "ipAddress":_"192.168.0.1",
    "ipSubnet": "255.255.255.0",
    "ipGateway":_"192.168.0.10",
    "ipDns": "192.168.0.10"
 _},
  "scripts":[
    "https://www.google.co.uk/1",
    "https://www.google.co.uk/2",
_   "https://www.google.co.uk/3"
  ]
}

As the devices_run minimal linux installs with busybox I_am using sed to_"parse"_the JSON and retrieve the values from_the_object._This_works fine for_single parameters such_as 
mac=$(echo $reply_| sed_-ne's/^.*"macAddress":"\([^"]*\)".*$/\1/p')
echo