Reading json data in Business Central

 Read JsonObject In Buisness Central AL Code

The following code is an example of how to read properties from a JsonObject. It is reading properties of the Json Object .

* Also reading text into json object as a bonus to our readers 👽

Scenario:

We are having simple Json value in a text type variable as an text and then reading out in a json object for having key and value properties so we can show it here how we are finding the key and value pair.


    var
     jsontext : text;
     jsonobj : JsonObject;
      JOrderNoToken: JsonToken;


    begin

        jsontext := '{"name": "test2908"}';

//  reading text value in json object

      jsonobj.readfrom(responseText);

         //  Now finding key and his value from json object created above

     jsonobj.Get('name', JOrderNoToken);

        Message('Name is %1', JOrderNoToken.AsValue().AsCode());

end;



Result will be :

Name is test2908

    

Comments

Post a Comment

Popular posts from this blog

Consume Rest API in Business Central Code with Basic Auth

How To do Hashing HMAC RSA 1 algorithm or cryptography in Microsoft Business Central | AL Code