---
title: "java拼接JSON串"
author: "anlinko"
date: "2019-10-23T09:53:36Z"
tags: ["Java"]
categories: ["编程语言"]
slug: "java-json"
draft: false
lastmod: "2019-10-23T09:53:36Z"
id: 2509150
url: "https://anlinko.iteye.com/blog/2509150"
---

```java

//java拼接JSON串
String str = "{\"route\":\"onGift\",\"time\":\"\",\"userId\":\"\",\"userName\":\"\",\"level\":\"1_2_2_2_0\",\"adminType\":0,\"tuserId\":\"\"," +
        "\"tuserName\":\"\",\"tlevel\":\"10_2_2_2_0\",\"roomId\":\"\",\"giftId\":\"001\",\"fcId\":\"0\",\"amount\":\"1\",\"price\":\"0\",\"bean\":\"6546316\"}";

JSONObject json = null;

try {
    json = new JSONObject(str);
} catch (JSONException e) {
    e.printStackTrace();
}



```