Adding nodes with JsonTextWritter

Hi everyone,
Probably is an easy question, but I can't find the way to do this. This is the structure of an XMLPort:


I need to generate a JSON with that structure, and I'm trying in this way:

LOCAL CreateSimpleJsonFile(VAR JSonResponse : DotNet "Newtonsoft.Json.Linq.JObject";peShopItem : Record "eShop Item")

  JSonResponse := JSonResponse.JObject();
  JsonTextWriter := JSonResponse.CreateWriter();
  JsonTextWriter.WritePropertyName('Ref');
  JsonTextWriter.WriteValue(peShopItem."No.");
  JsonTextWriter.WritePropertyName('DeleForEshop');
  JsonTextWriter.WriteValue(peShopItem."Delete-for Eshop");
  JsonTextWriter.WritePropertyName('Picture1');
  JsonTextWriter.WriteValue(peShopItem."Picture 1");
  JsonTextWriter.WritePropertyName('Category');
  JsonTextWriter.WriteValue(peShopItem."Item Category Code");
  JsonTextWriter.WritePropertyName('Subcategory');
  JsonTextWriter.WriteValue(peShopItem."Product Group Code");
  JsonTextWriter.WritePropertyName('SubcDescription');
  JsonTextWriter.WriteValue(peShopItem."Item Group Description");
  JsonTextWriter.WritePropertyName('Range');
  JsonTextWriter.WriteValue(peShopItem.Range);
  JsonTextWriter.WritePropertyName('Reading');
  JsonTextWriter.WriteValue(peShopItem.Reading);
  JsonTextWriter.WritePropertyName('WeightKg');
  JsonTextWriter.WriteValue(peShopItem."Weight (Kg)");
  leShopItembyShop.RESET;
  leShopItembyShop.SETRANGE("Item No.",peShopItem."No.");
  IF leShopItembyShop.FINDSET THEN REPEAT
    JsonTextWriter.WritePropertyName('eShopURL');
    JsonTextWriter.WriteValue(leShopItembyShop."eShop URL");
    JsonTextWriter.WritePropertyName('Enabled');
    JsonTextWriter.WriteValue(leShopItembyShop.Enabled);
    JsonTextWriter.WritePropertyName('Description');
    JsonTextWriter.WriteValue(leShopItembyShop.Description);
    JsonTextWriter.WritePropertyName('Availability');
    JsonTextWriter.WriteValue(leShopItembyShop.Availability);
    JsonTextWriter.WritePropertyName('GenericPrice');
    JsonTextWriter.WriteValue(leShopItembyShop."Generic Price");
    JsonTextWriter.WritePropertyName('InTransit');
    JsonTextWriter.WriteValue(leShopItembyShop."Qty. on Purch. Order");
    JsonTextWriter.WritePropertyName('FromTransitDate');
    JsonTextWriter.WriteValue(leShopItembyShop."Next Reception Date");
    JsonTextWriter.WritePropertyName('InCentral');
    JsonTextWriter.WriteValue(leShopItembyShop."Qty. on Origin");
    JsonTextWriter.WritePropertyName('FromCentralDate');
    JsonTextWriter.WriteValue(leShopItembyShop."Recep. Date-from Origin");
    JsonTextWriter.WritePropertyName('FromCentralDateText');
    JsonTextWriter.WriteValue(leShopItembyShop."Recep.-from Origin (Text)");
    JsonTextWriter.WritePropertyName('URLTechnicalCard');
    JsonTextWriter.WriteValue(leShopItembyShop."Technical Card url");
  UNTIL leShopItembyShop.NEXT = 0;

As you can imagine, after the findset I should create another deeper level of the json, but this is not working. What sentence should I use?

Thank you very much

Related
Recommended