How I modify a json node?

Help
loginmax
2012-05-21
2013-04-17
  • loginmax

    loginmax - 2012-05-21

    Hi, my code is

    var
     jso:TlkJSONobject;
     jsl:TlkJSONlist;
    begin
     CSalones.Close;
    //...
     CSalones.open;
     if not CSalones.IsEmpty
        then
         begin
            jsl:=TlkJSONlist.Create;
            CSalones.First;
            while not CSalones.Eof do
             begin
                jso:=TlkJSONobject.Create(true);
                jso.add('id',CSalonesSALON.value);
                jso.add('descripcion',CSalonesDESCRIPCION.value);
                jsl.Add(jso);
                CSalones.Next;
             end;
            TlkJSONstreamed.SaveToFile(jsl,destino);
            jsl.Destroy;
         end;
     CSalones.Close;
    

    The code generate this json, it is correct

    But, How I could add this preface?

    {"salones":

    }

     
  • loginmax

    loginmax - 2012-05-22

    The solution is create a object and encapsulate the list of objects

    jst:=TlkJSONobject.Create(true);
    jst.Add('salones',jsl);
    TlkJSONstreamed.SaveToFile(jst,destino);

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks