Skip to main content

Notifications

Announcements

No record found.

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

  • Vijayakumar@3009 Profile Picture
    Vijayakumar@3009 12 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    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

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,848 Super User 2024 Season 2 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    Hi, just adding some info. Hope the following helps as well.

    https://forum.mibuso.com/discussion/73034/json-best-way-to-read-them-on-dynamics-nav

    https://www.msnjournals.com/post/basics-of-json-data-types-in-business-central

    Thanks.

    ZHU

  • Suggested answer
    ShanAbeywicrema Profile Picture
    ShanAbeywicrema 940 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    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
    Govinda Kumar Profile Picture
    Govinda Kumar 2,198 Super User 2024 Season 1 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    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

  • Vijayakumar@3009 Profile Picture
    Vijayakumar@3009 12 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    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 .

  • Bilal Haider Profile Picture
    Bilal Haider 41 on at
    RE: Nav 2018 Json multiple values in a single text file through code

    What is Json table here and where it is filled ?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans