• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Laravel 5 controller sending JSON integer as string

phpjsonlaravellaravel-5php-5.6


PHP Snippet 1:

return response()->json(["foo" => "bar"], 200, [], JSON_NUMERIC_CHECK);

PHP Snippet 2:

return (int)Post::find(1)->id;

PHP Snippet 3:

class Controller extends BaseController {
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public static function json($json) {
        return response()->json($json, 200, [], JSON_NUMERIC_CHECK);
    }

PHP Snippet 4:

return self::json($all);

Related Snippets

selected value from the listbox in php

Facebook API, get page post link (PHP)

laravel 5.6 bulk inserting json data

Ajax GET request fails in laravel 8

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Change user role if checkout custom checkbox is checked in WooCommerce

Remove categories with all childs derived from parent category

Chunk and transpose a flat array into rows with a specific number of columns

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Show only featured products in Woocommerce shop page

Target Laravelista is not instantiable

GuzzleHttp Hangs When Using Localhost

MySQL default time format UTC or GMT?

Xdebug in Laravel is not working with VSCode

Add custom text under order details on WooCommerce My account view order pages

About Contact Privacy policy Terms and conditions