#1 2018-02-15 19:18:52

ViniciusGP
Member
Registered: 2018-02-15
Posts: 2

Json convertion

I'm using the framework and I'm really enjoying it, however I have a problem, and I would like help, I need to convert a string variable to the one Json object, and show this json on a grid. However I did not find an easy and quick way to do this conversion.

Offline

#2 2018-02-16 09:05:33

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Json convertion

Either you use a TStringGrid, or you use a TDataSet - see sample "17 - TClientDataset use".

See mORMotVCL.pas and its functions and classes, e.g. JSONTableToDataSet().

Offline

#3 2018-03-27 13:23:44

ViniciusGP
Member
Registered: 2018-02-15
Posts: 2

Re: Json convertion

So i need to convert a json with this structure:

[                                             
  {                                           
    "id": 1,                                   
    "type": "doc",                             
    "value": "AWFs8cbOGOSN1_MWPe-t",           
    "data": 2.716,                             
    "source":[ {                               
      "product": "17339896",               
      "description": "aasssdfsdaf"               
    }]                                         
   },                                         
  {                                           
    "id": 2,                                   
    "type": "doc",                             
    "value": "sadasfasSN1_MWPe-t",             
   "data": 124.467,                           
    "source": [{                               
      "product": "17339896",               
      "description": "aasssdfsdaf"               
    }  ]                                       
}]

And then convert this part to distinct columns
"source":[ {                               
      "product": "17339896",               
      "description": "aasssdfsdaf"               
    }]   


My Grid needs this configuration

________________________________________
|id | type | value | data | product | description |
----------------------------------------------

Last edited by ViniciusGP (2018-03-27 16:36:13)

Offline

Board footer

Powered by FluxBB