16

For the Json types it should also be possible to determine the formatting, e.g. by an additional parameter in the WriteTo function:

JsonObject.WriteTo(Stream, JsonFormat:: "Intended");


Or via a property on the JsonObject: JsonObject.Formatting := Formatting.Indented;


Why do we need this:

We have a case where we want to display the contents of a JSON file to the user in the interface. In this case, we want the JSON to be displayed formatted, i.e. with line breaks. The same JSON document should then be sent via a web service. In this case, unnecessary line breaks are to be avoided so that the transmission does not become unnecessarily larger.


In the past, we often used the code unit "Json Text/Reader Writer" to create the JSON file. The output format could be controlled here via the "SetDoNotFormat" property. However, we are trying to use the JSON types more since they support WriteTo(Stream) and it would be good if they provided the same formatting functionality.

Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team

Comments

J

Sounds like a good idea.Maybe you can add more JsonSerializerOptions like AllowTrailingCommas or JsonNumberHandling https://docs.microsoft.com/de-de/dotnet/api/system.text.json.jsonserializeroptions?view=net-6.0

Category: Development