bland-finland-95044
04/10/2025, 6:28 PMGroup:group1#members@User:user1
I see ory parse relationships
for converting from that format, but I don't see a way to convert to that formatbland-finland-95044
04/10/2025, 6:29 PMbland-finland-95044
04/10/2025, 7:30 PM# Define the input JSON file path and output file path
$inputFilePath = ".\relationships\relationships.json"
$outputFilePath = ".\relationships\relationships.keto"
$project_slug = "yourprojectslug"
ory list relationships --project $project_slug --page-size 10000 --format=json-pretty > $inputFilePath
# Read the JSON file
$jsonData = Get-Content -Path $inputFilePath | ConvertFrom-Json
# Initialize an array to store the Zanzibar notation relationships
$zanzibarRelationships = @()
# Iterate through each relationship in the JSON data
foreach ($relationship in $jsonData.relation_tuples) {
# Extract the components of the relationship
$namespace = $relationship.namespace
$object_id = $relationship.object
$relation = $relationship.relation
$subject = $relationship.subject_id
$subjectSet = $relationship.subject_set
# Construct the Zanzibar notation
# <https://storage.googleapis.com/gweb-research2023-media/pubtools/5068.pdf>
# tuple: object#relation@subject
# object: namespace:object_id
# subject: subject | subjectset
# subjectset: object#relation
if ($subjectSet) {
$subject = $subjectSet.namespace + ":" + $subjectSet.object + "#" + $subjectSet.relation
}
$zanzibarNotation = "$namespace`:$object_id#$relation@$subject"
$zanzibarRelationships += $zanzibarNotation
}
# Write the Zanzibar relationships to the output file
$zanzibarRelationships | Out-File -FilePath $outputFilePath -Encoding UTF8
# ory parse relationships .\relationships\relationships.keto --project $project_slug
Write-Host "Conversion complete! Zanzibar relationships saved to $outputFilePath"
magnificent-energy-493