Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Replace a value in Json file

(1) ShareShare
ReportReport
Posted on by 16
Hi all,
I'm trying to replace a value in a Json file, but I don't find any example or documentation for AL Language. I've the following structure file:
 
{ /codeunitId/: 18121808,/functionName/ : /PrintDocMaya/,/parmInput/: [{/name/: /pDocumentType/,/value/: /1/},{/name/: /pDocumentNo/,/value/: /102046/},{/name/: /pFilePath/,/value/: /C:////Temp/////}],/parmOutput/: [{/name/: /Return/,/value/:/0/}]}
 
I would like to replace value /0/ from parmOutput for the element with name /Return/. How could this be done?
 
Thank you for your kindly replies.
 
DZ
  • dzaniboni Profile Picture
    dzaniboni 16 on at
    Replace a value in Json file
    I develop this solution:
    • create new Json Object for the section of the original Json object that I want to replace.
    • Create new Json Array to store in a Json array the new results for the outputParm section.
    • Add in the new Json Object the new keys and values
    • Add the new Json Object in the Json Array
    • Replace the Json array for the specific key (that's an array)
     
    Below the code:
     
            OutputJObject.Add('name', 'Return');
            OutputJObject.Add('value', O_DocFileName);
            OutputArray.Add(OutputJObject);
            JObject.Replace('parmOutput', OutputArray);
     
     
    Hope this you can help.
     
    DZ
     
     
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 14,483 Most Valuable Professional on at
    Replace a value in Json file
    Hi
    In systemapplication is this code,  i hope this can help you. 
    BR
    Gerardo
  • dzaniboni Profile Picture
    dzaniboni 16 on at
    Replace a value in Json file
    Hi Mohamed,
    thank you for your reply but I'm able to create (from 0) or read a Json file. What I want is to know how to replace or modify an existing Json file (single values or properties).
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 15,652 Super User 2025 Season 1 on at
    Replace a value in Json file
    Hi dzaniboni
     
    I hope this can help you and give you some hints.
     
     
     
    Best regards,
    Mohamed Amine MAHMOUDI

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans