use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateJsonInArray.
@Test
public void testUpdateJsonInArray() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateJsonInArray");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "[\"a\",{\"country\":\"SriLanka\"},\"c\"]");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testUpdateString.
@Test
public void testUpdateString() {
BValue[] returns = BRunUtil.invoke(compileResult, "testUpdateString");
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 testAddBoolean.
@Test
public void testAddBoolean() {
BValue[] returns = BRunUtil.invoke(compileResult, "testAddBoolean");
Assert.assertTrue(returns[0] instanceof BJSON);
BJSON json = ((BJSON) returns[0]);
Assert.assertEquals(json.toString(), "{\"fname\":\"Supun\",\"status\":true}");
}
use of org.ballerinalang.model.values.BJSON in project ballerina by ballerina-lang.
the class BJSONValueTest method testAddJson.
@Test
public void testAddJson() {
BValue[] returns = BRunUtil.invoke(compileResult, "testAddJson");
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 JSONTest method testToXMLKeyValue.
@Test(description = "Convert json object with key value")
public void testToXMLKeyValue() {
BValue[] args = { new BJSON(jsonToXML15) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXML", args);
Assert.assertTrue(returns[0] instanceof BXML);
OMNode returnElement = ((BXMLItem) returns[0]).value();
Assert.assertEquals(returnElement.toString(), "<key>value</key>");
}
Aggregations