javascript - 如果 json 字符串包含 utf 8 个字符,则响应仅在 java 中给出一半数据
问题描述
这是预期结果。它适用于英文字符。
我遇到了问题如果 json String 包含任何其他语言字符,如日语、telegu 等。
我尝试使用 Print Writer 和 Base64 编码器等。但没有用帮助我解决这个问题
{
"categoryItems":{
"Dry Clean1":[
{
"id":3589,
"name":"చొక్కా",
"shortDescription":"",
"salesRate":0,
"image":"",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"hsnCode":"",
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3590,
"name":"Trouser",
"shortDescription":"",
"salesRate":0,
"image":"https://s3.ap-south-1.amazonaws.com/fkorg48//tie_coloring_page.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":",noPrint",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3591,
"name":"Jeans",
"shortDescription":"",
"salesRate":0,
"image":"fk_jeans",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3592,
"name":"Top",
"shortDescription":"",
"salesRate":0,
"image":"https://s3.ap-south-1.amazonaws.com/fkcustomer2468//ASSETPRODUCT/3592/top_1535197675847.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3593,
"name":"Saree",
"shortDescription":"",
"salesRate":50,
"image":"fk_saree",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":16393,
"name":"1kg",
"salesRate":300,
"image":"",
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"40",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"hsnCode":"",
"tags":"salesInfo,noPrint,noCount",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3594,
"name":"Blazer",
"shortDescription":"",
"salesRate":100,
"image":"https://s3.ap-south-1.amazonaws.com/fkcustomer48//ASSETPRODUCT/2692/lazer_1534504840207.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3595,
"name":"Skirt Pleated",
"shortDescription":"",
"salesRate":55,
"image":"fk_skirt_pleated",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
]
},
"taxes":[
{
"description":"",
"id":31,
"name":"CGST",
"rate":5,
"selectable":false,
"systemTax":false,
"tags":"",
"taxClass":"SI",
"taxType":null,
"taxes":"",
"uniqueCode":"CGST",
"version":0
},
{
"description":"",
"id":32,
"name":"SGST",
"rate":5,
"selectable":false,
"systemTax":false,
"tags":"",
"taxClass":"SI",
"taxType":null,
"taxes":"",
"uniqueCode":"SGST",
"version":0
}
]
}
这是实际结果它只显示半个 json 字符串。我怎么解决这个问题。
{
"categoryItems":{
"Dry Clean1":[
{
"id":3589,
"name":"చొక్కా",
"shortDescription":"",
"salesRate":0,
"image":"",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"hsnCode":"",
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3590,
"name":"Trouser",
"shortDescription":"",
"salesRate":0,
"image":"https://s3.ap-south-1.amazonaws.com/fkorg48//tie_coloring_page.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":",noPrint",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3591,
"name":"Jeans",
"shortDescription":"",
"salesRate":0,
"image":"fk_jeans",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"Yes",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3592,
"name":"Top",
"shortDescription":"",
"salesRate":0,
"image":"https://s3.ap-south-1.amazonaws.com/fkcustomer2468//ASSETPRODUCT/3592/top_1535197675847.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3593,
"name":"Saree",
"shortDescription":"",
"salesRate":50,
"image":"fk_saree",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":16393,
"name":"1kg",
"salesRate":300,
"image":"",
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"40",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"hsnCode":"",
"tags":"salesInfo,noPrint,noCount",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3594,
"name":"Blazer",
"shortDescription":"",
"salesRate":100,
"image":"https://s3.ap-south-1.amazonaws.com/fkcustomer48//ASSETPRODUCT/2692/lazer_1534504840207.png",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
{
"id":3595,
"name":"Skirt Pleated",
"shortDescription":"",
"salesRate":55,
"image":"fk_skirt_pleated",
"igst":5,
"cgst":5,
"sgst":5,
"state":"ACTIVE",
"value0":"1",
"value1":"No",
"value2":"",
"productposition":0,
"type":"Goods",
"stockInHand":0,
"tags":"",
"catalog":"Dry clean",
"catalogCategory":"Dry Clean1",
"categoryId":697,
"color":"#00f7ff",
"txtColor":"#000000",
"groupId":0
},
]
},
"taxes":[
{
"description":"",
"id":31,
"name":"CGST",
"rate":5,
"selectable":false,
"systemTax":false,
"tags":"",
"taxClass":"SI",
"taxType":null,
"taxes":"",
"uniqueCode":"CGST",
"version":0
},
{
"description":"",
"id":32,
"name":"SGST",
"rate":5,
"selectable":false,
"systemTax":false,
"tags":"",
"taxClass":"SI",
"taxType":null,
"taxes":"",
"uniqueCode":"SGST",
"
这是我的服务器代码
OutputStream out = null;
String jsonData = jsonObj.toString();
out = response.getOutputStream();
response.setContentLength(jsonData.length());
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Headers", "Content-Type");
response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
out.write(jsonData.getBytes(StandardCharsets.UTF_8);
out.flush();
解决方案
推荐阅读
- oracle - Oracle SQL:获取两个句子之间的文本
- c# - 想要在页面加载时填充列表框值而不使用 asp.net mvc 中的任何数据库
- python-3.x - 设置 len 的计算问题
- html - R blogdown:RSS提要生成的博客标题错误
- html - 如何平滑 CSS 渐变过渡?
- asp.net-core - NLog.Web.AspNetCore 布局渲染器为空
- javascript - Fullcalendar - 单独显示范围事件
- html - 有没有一种简单的方法可以在 Thymeleaf 中一起使用 th:data* 和 th:each 属性?
- asp.net - VB.Net - 如何将 GridView 中的 2 列作为数字进行比较?
- julia - 在 Julia 中调用多元牛顿法时的 SingularException(2)