Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json value convert error #68

Open
Ting-Yu opened this issue Jun 24, 2021 · 2 comments
Open

json value convert error #68

Ting-Yu opened this issue Jun 24, 2021 · 2 comments

Comments

@Ting-Yu
Copy link

Ting-Yu commented Jun 24, 2021

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
Copy link
Owner

mavinoo commented Jun 26, 2021

@mehmetbeyHZ

@mt-ks
Copy link
Contributor

mt-ks commented Jun 28, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants