viniciussanchez / dataset-serialize

JSON to DataSet and DataSet to JSON converter for Delphi and Lazarus (FPC)
MIT License
653 stars 161 forks source link

Não Importa Registros do NestedDataSet #154

Closed ageu closed 2 years ago

ageu commented 2 years ago

Tenho um Json do wordPress wooCommerce e não está trazendo o array de itens no dataset filho. Fiz conforme esta na descrição, criei o MemTable com o mesmo nome do campo "line_items" do json. segue o texto JSON:

[ { "id": 71735, "parent_id": 0, "status": "on-hold", "currency": "BRL", "version": "6.4.1", "prices_include_tax": false, "date_created": "2022-05-12T11:27:26", "date_modified": "2022-05-12T11:27:27", "discount_total": "0.00", "discount_tax": "0.00", "shipping_total": "0.00", "shipping_tax": "0.00", "cart_tax": "0.00", "total": "785.91", "total_tax": "0.00", "customer_id": 170, "order_key": "wc_order_a1hbDQSJ1Ca5b", "billing": { "first_name": "Teste Registro SA", "last_name": "Testando Registros", "company": "43435625000199", "address_1": "Rua Ruante, 00", "address_2": "Bairro Bairrante", "city": "Testelândia", "state": "SP", "postcode": "17541-000", "country": "BR", "email": "email2@email.com", "phone": "1434567898" }, "shipping": { "first_name": "Teste Registro SA", "last_name": "Testando Registros", "company": "43435625000199", "address_1": "Rua Ruante, 00", "address_2": "Bairro Bairrante", "city": "Testelândia", "state": "SP", "postcode": "17541-000", "country": "BR", "phone": "" }, "payment_method": "bacs", "payment_method_title": "Boleto parcelado", "transaction_id": "", "customer_ip_address": "179.96.150.192", "customer_user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/101.0.4951.64 Safari\/537.36", "created_via": "checkout", "customer_note": "", "date_completed": null, "date_paid": null, "cart_hash": "737b2299c111a83768ac376b252c9fb9", "number": "71735", "meta_data": [ { "id": 613548, "key": "is_vat_exempt", "value": "no" } ], "line_items": [ { "id": 25, "name": "Lâmpada Incandescente Bolinha 15W Laranja 127V", "product_id": 57312, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "3.12", "subtotal_tax": "0.00", "total": "3.12", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "1921", "price": 3.12000000000000010658141036401502788066864013671875, "parent_name": null }, { "id": 26, "name": "Martelo Unha 23Mm Tamboreado Mad", "product_id": 61124, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "20.80", "subtotal_tax": "0.00", "total": "20.80", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "5901", "price": 20.800000000000000710542735760100185871124267578125, "parent_name": null }, { "id": 27, "name": "Porta Sanfonada Neve 90Cm X2,10", "product_id": 62571, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "129.99", "subtotal_tax": "0.00", "total": "129.99", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "7751", "price": 129.990000000000009094947017729282379150390625, "parent_name": null }, { "id": 28, "name": "Conjunto Interruptor Simples + Interruptor Paralelo Aria (57241\/045)", "product_id": 60594, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "11.92", "subtotal_tax": "0.00", "total": "11.92", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "6829", "price": 11.9199999999999999289457264239899814128875732421875, "parent_name": null }, { "id": 29, "name": "Refletor Led 150W Bf 6500K Biv.", "product_id": 56722, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "183.58", "subtotal_tax": "0.00", "total": "183.58", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "8485", "price": 183.580000000000012505552149377763271331787109375, "parent_name": null }, { "id": 30, "name": "Igol Ecoasfalto - Balde 18L", "product_id": 63466, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "187.50", "subtotal_tax": "0.00", "total": "187.50", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "8307", "price": 187.5, "parent_name": null }, { "id": 31, "name": "Ventilador Valen Led Preto\/Preto 220V (707)", "product_id": 56460, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "249.00", "subtotal_tax": "0.00", "total": "249.00", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "7919", "price": 249, "parent_name": null } ], "tax_lines": [], "shipping_lines": [ { "id": 32, "method_title": "A definir", "method_id": "free_shipping", "instance_id": "5", "total": "0.00", "total_tax": "0.00", "taxes": [], "meta_data": [ { "id": 270, "key": "Itens", "value": "Lâmpada Incandescente Bolinha 15W Laranja 127V × 1, Martelo Unha 23Mm Tamboreado Mad × 1, Porta Sanfonada Neve 90Cm X2,10 × 1, Conjunto Interruptor Simples + Interruptor Paralelo Aria (57241\/045) × 1, Refletor Led 150W Bf 6500K Biv. × 1, Igol Ecoasfalto - Balde 18L × 1, Ventilador Valen Led Preto\/Preto 220V (707) × 1", "display_key": "Itens", "display_value": "Lâmpada Incandescente Bolinha 15W Laranja 127V × 1, Martelo Unha 23Mm Tamboreado Mad × 1, Porta Sanfonada Neve 90Cm X2,10 × 1, Conjunto Interruptor Simples + Interruptor Paralelo Aria (57241\/045) × 1, Refletor Led 150W Bf 6500K Biv. × 1, Igol Ecoasfalto - Balde 18L × 1, Ventilador Valen Led Preto\/Preto 220V (707) × 1" } ] } ], "fee_lines": [], "coupon_lines": [], "refunds": [], "payment_url": "https:\/\/jrfalcao.com\/site2\/finalizar-compra-2\/order-pay\/71735\/?pay_for_order=true&key=wc_order_a1hbDQSJ1Ca5b", "date_created_gmt": "2022-05-12T14:27:26", "date_modified_gmt": "2022-05-12T14:27:27", "date_completed_gmt": null, "date_paid_gmt": null, "currency_symbol": "R$", "_links": { "self": [ { "href": "https:\/\/jrfalcao.com\/site2\/wp-json\/wc\/v3\/orders\/71735" } ], "collection": [ { "href": "https:\/\/jrfalcao.com\/site2\/wp-json\/wc\/v3\/orders" } ], "customer": [ { "href": "https:\/\/jrfalcao.com\/site2\/wp-json\/wc\/v3\/customers\/170" } ] } } ]

viniciussanchez commented 2 years ago

Como está fazendo para importar para o dataset? Poderia postar o código?

ageu commented 2 years ago

eu tenho no form tres TFDMemtables mtPedido, mtLine_Items, mtBilling Estando todos ativos = false; O MasterSource = dsPedido; e não tem fields adicionados o JSon esta em um memo na tela mtPedido.LoadFromJSON(memo1.text); ele preenche corretamente o mtPedido e o mtBilling. Já o mtLine_Items fica vazio. Cheguei a pensar que pode ser por causa do underline do nome do componente.

viniciussanchez commented 2 years ago

Sim, provavelmente. Experimente alterar essa configuração para none:

image

ageu commented 2 years ago

Não deu certo Testei com todas as opções do CaseNameDefinition

viniciussanchez commented 2 years ago

Coloca como cndNone e altera o nome da sua memtable de mtLine_Items para mtline_items pra ver se da certo.

ageu commented 2 years ago

Deu certo!