我正在使用json.simple库。如果可能的话,我想坚持这一点。 当我检索一个对象
String blockString = message.get("block").toString();
然后
System.out.println(blockString)
给了我这个
{"type": "block", "transactions": [], "timestamp": "2017-11-02T06:17:05.079481", "reward": "b76364406658d679667e5e4be043f2da9d1f0e4ead17d78fcf152a5d718411c06d5dd2922cdb86a25d09c76dde7d26e8e26a55a90211bc6031f5d3b1cedc5b9c0577c01a1af3b8099261aa83fe6751c317662df130c10df56d4891fd8c1281a5d1bcb45d23b3096384b44a4a7af0e5217b7543eb68660914f936cdcdbe7b4c06851cb0efdef4c3859e7d38ac1da965430d498bcf4854b5d0470a421b2ddd50c61eac3f0e1f80f652daa90b5e1314a84e8fbadc7ad9dd1cdea613d7c292efe64f60d6ea2cbea0153701930a1fbf32d5d28a3d10e85adf8d2390dd7d551204f8fb430d8e0816f347269850751f6b00e23c1f125ff4cda7fd3de723e34aaaaa6599", "difficulty": "0", "nonce": "4c715812ebb33b38ec7546463112a3f9601dd05df13e4124f6ca5c491fb5d5883c941810da5dfa1a9902201af1c1d122476e1544a0ade75f7c05644ff25d8f2c", "parent": "00000f6c2e83499bd66b82128d523b4e6e17f289c938447c26f2edb20d382de818e332bf35349f92a5316657b9fd9a1e7b92b7c2aa709d7f487ea696582eec03"}
这正是我想要的。 现在,当我执行以下操作时:
JSONObject blockPayLoad = (JSONObject) JSONValue.parse(blockString);
然后
System.out.println(blockPayLoad.toString());
我明白了
{"reward":"b76364406658d679667e5e4be043f2da9d1f0e4ead17d78fcf152a5d718411c06d5dd2922cdb86a25d09c76dde7d26e8e26a55a90211bc6031f5d3b1cedc5b9c0577c01a1af3b8099261aa83fe6751c317662df130c10df56d4891fd8c1281a5d1bcb45d23b3096384b44a4a7af0e5217b7543eb68660914f936cdcdbe7b4c06851cb0efdef4c3859e7d38ac1da965430d498bcf4854b5d0470a421b2ddd50c61eac3f0e1f80f652daa90b5e1314a84e8fbadc7ad9dd1cdea613d7c292efe64f60d6ea2cbea0153701930a1fbf32d5d28a3d10e85adf8d2390dd7d551204f8fb430d8e0816f347269850751f6b00e23c1f125ff4cda7fd3de723e34aaaaa6599","difficulty":"0","parent":"00000f6c2e83499bd66b82128d523b4e6e17f289c938447c26f2edb20d382de818e332bf35349f92a5316657b9fd9a1e7b92b7c2aa709d7f487ea696582eec03","type":"block","transactions":[],"nonce":"4c715812ebb33b38ec7546463112a3f9601dd05df13e4124f6ca5c491fb5d5883c941810da5dfa1a9902201af1c1d122476e1544a0ade75f7c05644ff25d8f2c","timestamp":"2017-11-02T06:17:05.079481"}
所以两个问题/问题
原因是,我正在整理整个事物,因此我无法篡改对象的空格/顺序。