use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateJson.
@Test
public void testUpdateJson() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateJson");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"address\":{\"country\":\"SriLanka\"}}");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testStringAsJsonVal.
@Test(description = "Test initializing json with a string")
public void testStringAsJsonVal() {
BValue[] returns = BRunUtil.invoke(compileResult, "testStringAsJsonVal");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON person = ((BJSON) returns[0]);
Assert.assertEquals(person.value().asText(), "Supun");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testJsonStringToJson.
@Test
public void testJsonStringToJson() {
BValue[] returns = BRunUtil.invoke(compileResult, "testJsonStringToJson");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"name\", \"supun\"}");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateBooleanInArray.
@Test
public void testUpdateBooleanInArray() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateBooleanInArray");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "[\"a\",true,\"c\"]");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateFloatInArray.
@Test
public void testUpdateFloatInArray() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateFloatInArray");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "[\"a\",4.72,\"c\"]");
}
Aggregations