import com.getiox.plist.*
import kotlinx.datetime.Clock
val plistValue = mapOf(
"stringKey" to "stringValue".plistValue,
"intKey" to 123.plistValue,
"boolKey" to true.plistValue,
"realKey" to 123.456.plistValue,
"dateKey" to Clock.System.now().plistValue,
"dataKey" to byteArrayOf(1, 2, 3).plistValue,
"arrayKey" to listOf(1.plistValue, 2.plistValue, 3.plistValue).plistValue,
"dictKey" to mapOf(
"stringKey" to "stringValue".plistValue,
"intKey" to 123.plistValue
).plistValue
).plistValue
val binaryData = PList.encode(plistValue, PListFormat.BINARY)
val xmlData = PList.encode(plistValue, PListFormat.XML)
val decoded = PList.decode(binaryData)
if (decoded.isDict) {
val dict = decoded.dict
val stringValue = dict["stringKey"]?.string
val intValue = dict["intKey"]?.int
println("String value: $stringValue, Int value: $intValue")
}
import com.getiox.plist.*;
import java.util.List;
import java.util.Map;
PListValue root = new PListDict(Map.of(
"stringKey", new PListString("stringValue"),
"intKey", new PListInt(123),
"boolKey", new PListBool(true),
"realKey", new PListReal(123.456),
"dateKey", new PListDate(System.currentTimeMillis()),
"dataKey", new PListData(new byte[]{1, 2, 3}),
"arrayKey", new PListArray(List.of(
new PListInt(1),
new PListBool(false),
new PListReal(3.1415926)
)),
"dictKey", new PListDict(Map.of(
"stringKey", new PListString("stringValue"),
"intKey", new PListInt(123)
))
));
byte[] binaryData = PList.encode(root, PListFormat.BINARY);
byte[] xmlData = PList.encode(root, PListFormat.XML);
PListValue decoded = PList.decode(binaryData);
if(decoded instanceof
PListDict dict){
PListValue stringValue = dict.get("stringKey");
PListValue intValue = dict.get("intKey");
if(stringValue instanceof
PListString str &&intValue instanceof
PListInt num){
System.out.
println("String value: "+str.getValue() +", Int value: "+num.
getValue());
}
}