Jake Wilson
Jake Wilson

Reputation: 91213

PHP - Convert JSON to Plist?

How would one use PHP (and whatever necessary libraries) to convert JSON data to Plist data?

Upvotes: 0

Views: 1582

Answers (2)

genesis
genesis

Reputation: 50982

Transfer it into an array first. After that, do whatever you want with that

json_decode($json);

Upvotes: 1

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58371

I would decode the data and then encode it using CFPropertyList

Simply:

$plist = new CFPropertyList();    
$td = new CFTypeDetector();  
$guessedStructure = $td->toCFType( json_decode($json) );
$plist->add( $guessedStructure );
$xml = $plist->toXML();

Upvotes: 2

Related Questions