mavinoo / laravelBatch

insert batch and update batch in laravel
MIT License
564 stars 118 forks source link

json value convert error #68

Open Ting-Yu opened 3 years ago

Ting-Yu commented 3 years ago

src/Common/Common.php

protected static function safeJson($jsonData, $asArray = false)
{
    $jsonData     = json_decode($jsonData, true);
    $safeJsonData = [];
    if (!is_array($jsonData)) {
        return $jsonData;
    }
    foreach ($jsonData as $key => $value) {
        if (self::is_json($value)) {
            $safeJsonData[$key] = self::safeJson($value, true);
            if (gettype($safeJsonData[$key]) != gettype($value)) {
                $safeJsonData[$key] = $value;
            }
        } elseif (is_string($value)) {
            $safeJsonData[$key] = self::safeJsonString($value);
        } elseif (is_array($value)) {
            $safeJsonData[$key] = self::safeJson(json_encode($value), true);
        } else {
            $safeJsonData[$key] = $value;
        }
    }
    return $asArray ? $safeJsonData : json_encode($safeJsonData);
}
mavinoo commented 3 years ago

@mehmetbeyHZ

mt-ks commented 3 years ago

@Ting-Yu Can you send details? json data, db Pgsql - Mysql and Columns, errors .. etc