web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Nav 2018 Json multiple values in a single text file through code

(0) ShareShare
ReportReport
Posted on by 12

I need to get JSON file with multiple values in a single text file through code unit . As my code I'm getting a single value in a text file as JSON . Can anyone suggest answers? I'm using Nav 2018 version as i checked google 2016 codes are available I referred 2016 code and it's work a bit but I got single value only.

MY CODE.
CreateSimpleJsonFile(jsonresponse);

LOCAL CreateSimpleJsonFile(JSONresponse : DotNet "Newtonsoft.Json.Linq.JObject")

JSONresponse := JSONresponse.JObject();
JsonTxtWriter:= JSONresponse.CreateWriter();
IF jsontable.FINDSET THEN BEGIN
REPEAT
JsonTxtWriter.WritePropertyName('No');
JsonTxtWriter.WriteValue(jsontable.No);
JsonTxtWriter.WritePropertyName('Name');
JsonTxtWriter.WriteValue(jsontable.Name);
MESSAGE('No: %1; Name: %2',FORMAT(JSONresponse.GetValue('No')), FORMAT(JSONresponse.GetValue('Name')),jsonstring);

UNTIL jsontable.NEXT=0;
END ;
IF jsontable.FINDSET THEN BEGIN
jsonstring:= JSONresponse.ToString();
Myfile.CREATE('D:\Jsontext1.txt');
Myfile.CREATEOUTSTREAM(Outstr);
REPEAT
noofchar:= Outstr.WRITETEXT(FORMAT(jsontable));
UNTIL jsontable.NEXT=0;
END;

Kindly anyone refer a good answer .

Thanks & Regards
Vijay

I have the same question (0)
  • Bilal Haider Profile Picture
    442 on at

    What is Json table here and where it is filled ?

  • Vijayakumar@3009 Profile Picture
    12 on at

    Annotation-2023_2D00_03_2D00_30-105347.pngAnnotation-2023_2D00_03_2D00_30-110031.png_2D00_700x758.png_2D00_640x480.pngFirst Screenshot is my table I need all data's as json text file but im currently getting as second screenshot only the 4th value Printing 4 times .

  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi Vijayakumar@3009,

    I had a similar requirement many days ago.. and was able to find a solution through this link..

    www.dvlprlife.com/.../

    I hope this helps you too.

    Regards

  • Suggested answer
    ShanAbeywicrema Profile Picture
    948 on at

    Hi,

    Please refer bellow URLs, it might be helpful for you.

    community.dynamics.com/.../938056

    you can validate your JSON file from here

    https://jsonformatter.org/

  • Suggested answer
    YUN ZHU Profile Picture
    99,084 Super User 2026 Season 1 on at
  • Vijayakumar@3009 Profile Picture
    12 on at

    Hi Ji thanks for your help for me the code is works good but while saving the file I gets override to my records I have attached the Screenshot in before message

    Thanks & Regards

    Vijayakumar K

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans