Laravel - Collections - Method Tojson

The toJson method converts the collection into a JSON serialized string:

    
    $collection = collect(['name' => 'Desk', 'price' => 200]);
    
    $collection->toJson();
    
    // '{"name":"Desk", "price":200}'