相关疑难解决方法(0)

使用变量动态访问对象属性

我正在尝试使用动态名称访问对象的属性.这可能吗?

const something = { bar: "Foobar!" };
const foo = 'bar';
something.foo; // The idea is to access something.bar, getting "Foobar!"
Run Code Online (Sandbox Code Playgroud)

javascript properties object

654
推荐指数
10
解决办法
31万
查看次数

如何从Android发布JSON字符串

我试图在Android服务器上发布json时遇到问题.错误是:

加载JSON失败.请求中不得包含特殊字符.请检查所请求的JSON.

我遵循了许多例子,但没有一个是有帮助的.请提供解决方案或帮助我在代码中找到问题.

下面是在服务器上发布JSON字符串的代码.

public class JSONParser {

    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";

    // constructor
    public JSONParser() {

    }

    public JSONObject getJSONFromUrl(String url) {

        // Making HTTP request
        try {
            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            /* ====================================================================================================*/

                        JSONObject listobj = new JSONObject ();
                        JSONObject listInvoice = new JSONObject ();
                        listInvoice.put("client_id","");
                        listInvoice.put("date_from","");
                        listInvoice.put("date_to","");
                        listInvoice.put("invoice_number","");
                        listInvoice.put("invoice_record_status","");
                        listInvoice.put("invoice_status","");
                        listInvoice.put("page","1");
                        listInvoice.put("per_page_record","10");
                        listobj.put("listInvoice", listInvoice);


                      //--List nameValuePairs = new …
Run Code Online (Sandbox Code Playgroud)

parsing android json

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

javascript ×1

json ×1

object ×1

parsing ×1

properties ×1