如何在Flutter中解码JSON? [英] How to decode JSON in Flutter?

查看:238
本文介绍了如何在Flutter中解码JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Flutter中解码JSON?

这个问题很简单,但答案并非如此,至少对我而言.

我有一个使用大量JSON字符串的项目.基本上,应用程序和服务器之间的整个通信都是通过JSON.

我一直在使用JSON.decode(json_string)来处理它,但是今天我更新了Flutter核心(0.5.8-pre.178),并且JSON.decode不再可用.

我去了 Flutter Docs 寻求帮助,但它仍然说要使用JSON.decode. /p>

那么,从现在开始如何在Flutter中解码JSON?

解决方案

只需使用

json.decode()

jsonDecode()

在Dart 2中,所有尖叫情况下的常量都更改为小写驼峰.

How to decode JSON in Flutter?

The question is simple, but the answer isn't, at least for me.

I have a project that uses a lot of JSON Strings. Basically, the entire communication between the app and the server is through JSON.

I have been using JSON.decode(json_string) to deal with it, but today I updated the Flutter core (0.5.8-pre.178) and JSON.decode isn't available anymore.

I went to the Flutter Docs to seek help, but it still says to use JSON.decode.

So, how to decode JSON in Flutter from now on?

解决方案

Just use

json.decode()

or

jsonDecode()

In Dart 2 all screaming-case constants were changed to lower-camel-case.

这篇关于如何在Flutter中解码JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆