I don't have any sample code for constructing a JSON file, but table 1236 has lots of functions attached for JSON data handling. I've put some sample code below, but this reads data from a JSON file rather than trying to construct a JSON file. I think the process would basically be to add data to the JSON table, and then call a method that exports that as JSON into a BLOB.
My advice would be to make yourself a docker container with NAV 2018. Pull out all of the objects as text, and see if you can find any example code in those objects that is calling and using Table 1236.
IF NOT HTTPWebRequestMgt.GetResponse(WebInStream, HTTPStatusCode, ResponseHeaders) THEN BEGIN
HTTPWebRequestMgt.ProcessFaultResponse(Response);
ERROR(Response);
END;
WebInStream.READTEXT(Response);
CLEAR(JSONBuffer);
JSONBuffer.ReadFromText(Response);
IF JSONBuffer.GetDecimalPropertyValue(Mileage, 'travelDistance') THEN
MESSAGE(FORMAT(Mileage));
END;
Answers
Which version of NAV I have to look for ?
My advice would be to make yourself a docker container with NAV 2018. Pull out all of the objects as text, and see if you can find any example code in those objects that is calling and using Table 1236.
PROCEDURE BingDistance@1240060001();
VAR
TempBLOB@1240060005 : Record 99008535;
JSONBuffer@1240060010 : TEMPORARY Record 1236;
HTTPWebRequestMgt@1240060002 : Codeunit 1297;
WebOutStream@1240060004 : OutStream;
WebInStream@1240060003 : InStream;
HTTPStatusCode@1240060008 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpStatusCode";
ResponseHeaders@1240060006 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Specialized.NameValueCollection";
URL@1240060000 : Text;
Response@1240060007 : Text;
Mileage@1240060011 : Decimal;
BEGIN
URL := 'https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins=3.98344,-8.20666&destinations=3.78122,-8.39699';
URL := URL + '&travelMode=driving&startTime=2:00:00-05:00&distanceUnit=mile';
HTTPWebRequestMgt.Initialize(URL);
IF NOT GUIALLOWED THEN
HTTPWebRequestMgt.DisableUI();
HTTPWebRequestMgt.SetReturnType('application/json');
CLEAR(TempBLOB);
CLEAR(WebInStream);
TempBLOB.Blob.CREATEINSTREAM(WebInStream);
IF NOT HTTPWebRequestMgt.GetResponse(WebInStream, HTTPStatusCode, ResponseHeaders) THEN BEGIN
HTTPWebRequestMgt.ProcessFaultResponse(Response);
ERROR(Response);
END;
WebInStream.READTEXT(Response);
CLEAR(JSONBuffer);
JSONBuffer.ReadFromText(Response);
IF JSONBuffer.GetDecimalPropertyValue(Mileage, 'travelDistance') THEN
MESSAGE(FORMAT(Mileage));
END;