Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从azure服务队列接收JSON时,在JSON结束后附加一些重复值_Java_Json_Azure_Azure Servicebus Queues - Fatal编程技术网

Java 从azure服务队列接收JSON时,在JSON结束后附加一些重复值

Java 从azure服务队列接收JSON时,在JSON结束后附加一些重复值,java,json,azure,azure-servicebus-queues,Java,Json,Azure,Azure Servicebus Queues,我面临着代码的两难选择, 我的问题是,当我通过这段代码向Azure服务总线发送JSon时 BrokeredMessage message = new BrokeredMessage(jsonStr); 并在发送方代码中打印JSON,通过 System.out.println("Json---"+jsonStr); 这很好用。 但是,当我通过同一Azure服务总线从队列接收JSON列表时,我能够接收到它,但在JSON列表完成后会附加一些重复的结束字段。 我正在使用以下代码: if

我面临着代码的两难选择, 我的问题是,当我通过这段代码向Azure服务总线发送JSon时

 BrokeredMessage message = new BrokeredMessage(jsonStr);
并在发送方代码中打印JSON,通过

System.out.println("Json---"+jsonStr);
这很好用。 但是,当我通过同一Azure服务总线从队列接收JSON列表时,我能够接收到它,但在JSON列表完成后会附加一些重复的结束字段。 我正在使用以下代码:

     if (message != null && message.getMessageId() != null)
                {
                    System.out.println("MessageID: " + message.getMessageId());


                    // Display the queue message.
                    System.out.print("From queue: ");
                  byte[] b = new byte[200];

                  String s = null;
                    int numRead = message.getBody().read(b);
                   System.out.println("numread--"+numRead);
                    while (-1 != numRead)
                    {
                        s = new String(b);
                        s = s.trim();

                        System.out.print(s);
                        numRead = message.getBody().read(b);
                        //System.out.println("numread--"+numRead);
                    }
} 
我得到的输出是在末尾附加重复字段:

"oldPartNumber": null,
        "materialType": "4",
        "materialGroup": "HX",
        "bulkItemFlag": "N",
            "flexStringCollab04": null,
            "flexStringCollab05": null,
            "blockShipments": null,
            "earlyShipmentTolerance": 0,
            "overShipmentTolerance": 0.0,
            "priceMismatchToleranceMin": 0.0,
            "priceMismatchToleranceMax": 0.0
          }
        }
      ],
      "grFF": null
    }ingCollab04":null,"flexStringCollab05":null,"blockShipments":null,"earlyShipmentTolerance":0,"overShipmentTolerance":0.0,"priceMismatchToleranceMin":0.0,"priceMismatchTo
您可以看到,即使在从队列中完成JSOn列表之后,输出中也会重复最后几个字段。我没有粘贴整个JSOn,因为问题只在最后,我的JSOn列表不知何故包含了更多字段。 我想消除这个问题

谢谢你的帮助。
提前谢谢

听起来不对。如何开始将消息写入队列?@SeanFeldman我正在将消息发送到Azure服务队列。使用代理消息类并使用以下代码行:service.sendQueueMessage(“sq-jcibe-microservice-e2open-dev”,Message);BrokeredMessage是使用有效的JSON构造的吗?如果是这样的话,我建议针对本回购协议发行债券: