Close

Argentum got a two-way JSON support

A project log for Argentum programming language

It automatically prevents all memory leaks. It doesn't use GC, so no pauses. It's compiled to machine code. It's crazy safe and fast.

andrey-kalmatskiyAndrey Kalmatskiy 12/23/2024 at 04:480 Comments

Argentum got a JSON module with both Parser and Writer.

Let's try Writer in action:

We'll use the same classes as in JSON Parser example:

class Point{
    x = 0f;
    y = 0f;
} 
class Polygon {
    name = "";
    points = Array(Point);
    isActive = false;
}

 This function converts an array of Polygons into a JSON string:

fn polygonsToJson(data Array(Polygon)) str {
    Writer.useTabs().arr {
        data.each `poly _.obj {
            _("name").str(poly.name);
            _("active").bool(poly.isActive);
            _("points").arr\poly.points.each `pt _.obj {
                _("x").num(double(pt.x));
                _("y").num(double(pt.y))
            }
        }
    }.toStr()
}

Discussions