use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testAddString.
@Test
public void testAddString() {
BValue[] returns = BRunUtil.invoke(compileResult, "testAddString");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"lname\":\"Setunga\"}");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testIntAsJsonVal.
@Test(description = "Test initializing json with an integer")
public void testIntAsJsonVal() {
BValue[] returns = BRunUtil.invoke(compileResult, "testIntAsJsonVal");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON person = ((BJSON) returns[0]);
Assert.assertEquals(person.value().longValue(), 5);
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateInt.
@Test
public void testUpdateInt() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateInt");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"age\":25}");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testFloatAsJsonVal.
@Test(description = "Test initializing json with a float")
public void testFloatAsJsonVal() {
BValue[] returns = BRunUtil.invoke(compileResult, "testFloatAsJsonVal");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON person = ((BJSON) returns[0]);
Assert.assertEquals(person.value().doubleValue(), 7.65);
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testJSONWithExpressionKey.
@Test
public void testJSONWithExpressionKey() {
CompileResult result = BCompileUtil.compile("test-src/types/jsontype/json-literal-with-expr-key.bal");
BValue[] returns = BRunUtil.invoke(result, "testJSONWithExpressionKey");
Assert.assertTrue(returns[0] instanceof BJSON);
Assert.assertEquals(returns[0].stringValue(), "{\"a\":\"Lion\",\"key1\":\"Cat\",\"key2\":\"Dog\"}");
}
Aggregations