Skip to content

Instantly share code, notes, and snippets.

@ballerina-github-bot
ballerina-github-bot / play.bal
Created November 23, 2023 01:34
Ballerina Playground
import ballerina/io;
type Student record {|
int id;
string name;
|};
public function main() returns error? {
// As JSON is a union: `()|boolean|int|float|decimal|string|json[]|map<json>`,
// the following cases are allowed.
@ballerina-github-bot
ballerina-github-bot / play.bal
Created November 22, 2023 23:39
Ballerina Playground
import ballerina/io;
public function main() {
io:println("Hello, World!");
}
@ballerina-github-bot
ballerina-github-bot / play.bal
Created November 2, 2023 03:08
Ballerina Playground
import ballerina/http;
import ballerina/io;
// Define an open record type to describe both the payload on the wire and the data in memory
type Country record {
string country;
int population;
string continent;
int cases;
int deaths;
@ballerina-github-bot
ballerina-github-bot / play.bal
Created October 24, 2023 12:38
Ballerina Playground
import ballerina/io;
import record_to_edi.sorder;
public function main() returns error? {
sorder:SimpleOrder simpleOrder =
{header: {code: "HDR", orderId: "ORDER_200", organization: "HMart", date: "17-05-2023"}};
simpleOrder.items.push({code: "ITM", item: "A680", quantity: 15});
simpleOrder.items.push({code: "ITM", item: "A530", quantity: 2});
simpleOrder.items.push({code: "ITM", item: "A500", quantity: 4});
string ediText = check sorder:toEdiString(simpleOrder);
@ballerina-github-bot
ballerina-github-bot / play.bal
Created October 17, 2023 09:17
Ballerina Playground
import ballerina/io;
public function main() {
io:println("Hello Ballerina!");
}
@ballerina-github-bot
ballerina-github-bot / play.bal
Created October 5, 2023 09:19
Ballerina Playground
[wrapping]
simpleBlocksInOneLine = true
[spacing]
aroundRecordBraces = true
[methodDeclaration]
parametersWrap = "ChopDown"
alignMultilineParameters = true
@ballerina-github-bot
ballerina-github-bot / play.bal
Created October 5, 2023 09:18
Ballerina Playground
import ballerina/http;
import ballerina/io;
// Define an open record type to describe both the payload on the wire and the data in memory
type Country record {
string country;
int population;
string continent;
int cases;
int deaths;
@ballerina-github-bot
ballerina-github-bot / constraint_validations.bal
Created September 25, 2023 06:03
examples/constraint-validations
import ballerina/constraint;
// Constraint on the `int` type.
@constraint:Int {
minValue: 18
}
type Age int;
type Student record {|
// Constraint on the `string`-typed record field.
@ballerina-github-bot
ballerina-github-bot / xml_from_record_conversion.bal
Created September 25, 2023 06:03
examples/xml-from-record-conversion
import ballerina/io;
import ballerina/xmldata;
// Defines a record type with annotations.
@xmldata:Namespace {
prefix: "ns",
uri: "http://sdf.com"
}
type Invoice record {
int id;
@ballerina-github-bot
ballerina-github-bot / xml_to_record_conversion.bal
Created September 25, 2023 06:03
examples/xml-to-record-conversion
import ballerina/io;
import ballerina/xmldata;
// Defines a record type with annotations.
@xmldata:Namespace {
prefix: "ns",
uri: "http://sdf.com"
}
type Invoice record {
int id;