我有一个非常长的JSON,我需要使用Google的json-simple API进行解析。但是,json-simple API不解析完整的JSON字符串。下面是我解析JSON的Java代码。输出没有完整的JSON字符串。
json-simple API在解析JSON时是否有任何限制?或者我在代码中遗漏了什么?
请帮忙!非常感谢!
此致 维纳亚克
Java代码:
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class JSONParser {
private static final String JSON_DATA = "{\"order\":{\"entityErrors\":[],\"buyerInfo\":{\"id\":\"7b70f71b-6337-4726-befe-c6cf50c8f413\",\"isGuest\":false,\"associateInfo\":{\"shouldApplyAssociateDiscount\":true},\"primaryContact\":{\"name\":{\"completeName\":\"Yugesh Gundapaneni\",\"firstName\":\"Yugesh\",\"lastName\":\"Gundapaneni\"},\"phone\":{\"completeNumber\":\"408-660-5027\"},\"email\":{\"emailAddress\":\"ygundapaneni@abc.com\"}}},\"groupOrderNo\":\"1414451219356\",\"orderNo\":\"1414451219356\",\"orderType\":\"DOMESTIC\",\"orderDate\":\"2014-10-08T21:11:21Z\",\"orderLines\":[{\"seller\":{\"catalogSellerId\":0,\"partnerDisplayName\":\"abc.com\"},\"primeLineNo\":1,\"orderedQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"fulfillmentType\":\"S2S\",\"shippingMethod\":\"STORE_DELIVERY\",\"giftMessage\":{\"giftMessage\":\" GIFT\"},\"orderProduct\":{\"offerId\":{\"offerId\":\"539A698868664B2DB87ECB061D328722\",\"upc\":\"0005436107672\",\"wupc\":\"0005436107672\",\"USItemId\":10154038,\"USSellerId\":0},\"productName\":\"Stansport G-8-10 Folding Stadium Seat with Arms\",\"offerAttributes\":{\"isMailReturnable\":true,\"isPerishable\":false,\"wmDeptNo\":\"74\"}},\"unitPrice\":{\"currencyAmount\":20.00,\"currencyUnit\":\"USD\"},\"shipToAddress\":{\"address\":{\"addressLineOne\":\"600 showers drive\",\"addressLineTwo\":\"\",\"addressLineThree\":\"\",\"addressLineFour\":\"\",\"addressLineFive\":\"\",\"addressLineSix\":\"\",\"addressType\":\"OFFICE\",\"city\":\"MountainView\",\"countryCode\":\"USA\",\"postalCode\":\"94040\",\"stateOrProvinceCode\":\"CA\",\"id\":null,\"isApoFpo\":false,\"isPoBox\":false},\"storeFrontId\":{\"storeFrontId\":null,\"USStoreId\":5502},\"name\":{\"firstName\":\"\",\"middleName\":\"\",\"lastName\":\"\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"\"},\"smsMobileNo\":{\"completeNumber\":\"\"},\"email\":{\"emailAddress\":\"\"}},\"orderedLineDates\":[{\"dateTypeId\":\"DELIVERY\",\"expectedDate\":\"2014-10-10T21:11:21Z\"}],\"charges\":[{\"chargeCategory\":\"DISCOUNT\",\"chargeName\":\"AssociateDiscount\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"chargePerUnit\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"},\"chargePerLine\":{\"currencyAmount\":0.00,\"currencyUnit\":\"USD\"},\"isDiscount\":true,\"isBillable\":true},{\"chargeCategory\":\"FEE\",\"chargeName\":\"Fee1\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"tax\":[{\"taxName\":\"Fee1\",\"taxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"},\"estimatedTaxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"}}]},{\"chargeCategory\":\"PRODUCT\",\"chargeName\":\"Product\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"chargePerUnit\":{\"currencyAmount\":20.00,\"currencyUnit\":\"USD\"},\"tax\":[{\"taxName\":\"Tax1\",\"taxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"},\"estimatedTaxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"}}]}],\"orderLineQuantityInfo\":[{\"status\":\"PROCESSING\",\"statusCode\":\"2100.200\",\"statusDescription\":\"PO Created\",\"statusChangeDate\":\"2014-12-04T10:19:05Z\",\"statusQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}}],\"orderLineNote\":[],\"lineQuantitySummaries\":[{\"type\":\"Invoiced\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"Ordered\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}},{\"type\":\"Received\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"Shipped\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"IntentToCancel\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":1.0}},{\"type\":\"IntentToCancel\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":1.0}}],\"holds\":[],\"returnInfo\":{\"openRMAQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00},\"returnableQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00},\"isCallTagRequired\":false}},{\"seller\":{\"catalogSellerId\":0,\"partnerDisplayName\":\"abc.com\"},\"primeLineNo\":2,\"orderedQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"fulfillmentType\":\"ELECTRONIC\",\"shippingMethod\":\"ELECTRONIC_DELIVERY\",\"orderProduct\":{\"offerId\":{\"offerId\":\"CFE4D1981AC746E89ABBCBCBAE6F024F\",\"upc\":\"0005436107673\",\"wupc\":\"0005436107673\",\"USItemId\":24074298,\"USSellerId\":0},\"productName\":\"LOYAL MK472B\",\"offerAttributes\":{\"isMailReturnable\":true,\"isPerishable\":false,\"wmDeptNo\":\"\"}},\"unitPrice\":{\"currencyAmount\":10.00,\"currencyUnit\":\"USD\"},\"shipToAddress\":{\"address\":{\"addressLineOne\":\"600 showers drive\",\"addressLineTwo\":\"\",\"addressLineThree\":\"\",\"addressLineFour\":\"\",\"addressLineFive\":\"\",\"addressLineSix\":\"\",\"addressType\":\"OFFICE\",\"city\":\"MountainView\",\"countryCode\":\"USA\",\"postalCode\":\"94040\",\"stateOrProvinceCode\":\"CA\",\"id\":null,\"isApoFpo\":false,\"isPoBox\":false},\"storeFrontId\":{\"storeFrontId\":null,\"USStoreId\":5502},\"name\":{\"firstName\":\"\",\"middleName\":\"\",\"lastName\":\"\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"\"},\"smsMobileNo\":{\"completeNumber\":\"\"},\"email\":{\"emailAddress\":\"\"}},\"orderedLineDates\":[{\"dateTypeId\":\"DELIVERY\",\"expectedDate\":\"2014-09-30T19:36:22Z\"}],\"charges\":[{\"chargeCategory\":\"DISCOUNT\",\"chargeName\":\"AssociateDiscount\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"chargePerUnit\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"},\"chargePerLine\":{\"currencyAmount\":0.00,\"currencyUnit\":\"USD\"},\"isDiscount\":true,\"isBillable\":true},{\"chargeCategory\":\"FEE\",\"chargeName\":\"Fee1\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"tax\":[{\"taxName\":\"Fee1\",\"taxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"},\"estimatedTaxPerLine\":{\"currencyAmount\":1.00,\"currencyUnit\":\"USD\"}}]},{\"chargeCategory\":\"PRODUCT\",\"chargeName\":\"Product\",\"chargeQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"chargePerUnit\":{\"currencyAmount\":10.00,\"currencyUnit\":\"USD\"},\"tax\":[{\"taxName\":\"Tax1\",\"taxPerLine\":{\"currencyAmount\":4.00,\"currencyUnit\":\"USD\"},\"estimatedTaxPerLine\":{\"currencyAmount\":4.00,\"currencyUnit\":\"USD\"}}]}],\"orderLineQuantityInfo\":[{\"status\":\"PROCESSING\",\"statusCode\":\"2100.200\",\"statusDescription\":\"PO Created\",\"statusChangeDate\":\"2014-10-27T16:07:22Z\",\"statusQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}}],\"orderLineNote\":[],\"lineQuantitySummaries\":[{\"type\":\"Invoiced\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"Ordered\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}},{\"type\":\"Received\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"Shipped\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00}},{\"type\":\"IntentToCancel\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":1.0}},{\"type\":\"IntentToCancel\",\"quantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":1.0}}],\"holds\":[],\"returnInfo\":{\"openRMAQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00},\"returnableQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":0.00},\"isCallTagRequired\":false}}],\"paymentMethods\":[{\"paymentType\":\"CREDITCARD\",\"pmId\":\"VISA\",\"last4DigitsOfCard\":\"2725\",\"personInfoBillTo\":{\"address\":{\"addressLineOne\":\"850 Cherry Ave\",\"addressLineTwo\":\"\",\"addressLineThree\":\"\",\"addressLineFour\":\"\",\"addressLineFive\":\"\",\"addressLineSix\":\"\",\"city\":\"San Bruno\",\"countryCode\":\"USA\",\"postalCode\":\"94066\",\"stateOrProvinceCode\":\"CA\",\"id\":null,\"isApoFpo\":false,\"isPoBox\":false},\"name\":{\"completeName\":\"YUGESH GUNDAPANENI\",\"firstName\":\"YUGESH\",\"middleName\":\"\",\"lastName\":\"GUNDAPANENI\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"408-660-5027\"},\"smsMobileNo\":{\"completeNumber\":\"408-660-5027\"},\"email\":{\"emailAddress\":\"ygundapaneni@abc.com\"}},\"amountpromised\":{\"currencyAmount\":100.00,\"currencyUnit\":\"USD\"},\"paymentReferenceId\":\"ca005e30-210b-4c23-b8ad-60adcdcea744\"}],\"shipments\":[],\"pickupPersons\":[{\"contactInfo\":{\"name\":{\"completeName\":\"YUGESH GUNDAPANENI\",\"firstName\":\"YUGESH\",\"middleName\":\"\",\"lastName\":\"GUNDAPANENI\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"408-660-5027\"},\"smsMobileNo\":{\"completeNumber\":\"408-660-5027\"},\"email\":{\"emailAddress\":\"ygundapaneni@abc.com\"}},\"isPrimary\":false},{\"contactInfo\":{\"name\":{\"completeName\":\"YUGESH GUNDAPANENI\",\"firstName\":\"YUGESH\",\"middleName\":\"\",\"lastName\":\"GUNDAPANENI\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"408-660-5027\"},\"smsMobileNo\":{\"completeNumber\":\"408-660-5027\"},\"email\":{\"emailAddress\":\"ygundapaneni@abc.com\"}},\"isPrimary\":true},{\"contactInfo\":{\"name\":{\"completeName\":\"Jane George\",\"firstName\":\"Jane\",\"middleName\":\"\",\"lastName\":\"George\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"9995443333\"},\"smsMobileNo\":{\"completeNumber\":\"3436758989\"},\"email\":{\"emailAddress\":\"jane@abc.com\"}},\"isPrimary\":false}],\"lastModified\":\"2014-12-10T10:06:19Z\",\"orderNote\":[{\"contactType\":\"Account\",\"contactReference\":\"\",\"contactTime\":\"2014-10-27T16:07:00Z\",\"noteText\":\"Note dude\",\"reasonCode\":\"\",\"enteredBy\":\"Customer\"}],\"holds\":[],\"orderLineRelationships\":{\"warrantyRelationships\":[{\"productLine\":{\"productLineNo\":\"1\"},\"warrantyLine\":{\"warrantyLineNo\":\"2\"}}]},\"purchaseOrders\":[{\"purchaseOrderNo\":\"1569570013125\",\"shipNode\":\"2377\",\"shipNodeType\":\"DC\",\"scac\":\"\",\"tcNumber\":\"02237020963141852820177\",\"shipToAddress\":{\"address\":{\"addressLineOne\":\"600 showers drive\",\"addressLineTwo\":\"\",\"addressLineThree\":\"\",\"addressLineFour\":\"\",\"addressLineFive\":\"\",\"addressLineSix\":\"\",\"addressType\":\"OFFICE\",\"city\":\"MountainView\",\"countryCode\":\"USA\",\"postalCode\":\"94040\",\"stateOrProvinceCode\":\"CA\",\"id\":null,\"isApoFpo\":false,\"isPoBox\":false},\"storeFrontId\":{\"storeFrontId\":null,\"USStoreId\":5502},\"name\":{\"firstName\":\"\",\"middleName\":\"\",\"lastName\":\"\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"\"},\"smsMobileNo\":{\"completeNumber\":\"\"},\"email\":{\"emailAddress\":\"\"}},\"poDate\":[],\"purchaseOrderLines\":[{\"poLineId\":\"2\",\"primeLineNo\":2,\"poLineStatusInfos\":[{\"poLineStatus\":\"1100.200\",\"poLineStatusCode\":\"1100.200\",\"poLineStatusDescription\":\"PO Created\",\"poLineStatusChangeDate\":\"2014-10-27T16:07:22Z\",\"poLineStatusQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}}],\"orderedQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"requestOfferId\":{\"offerId\":\"CFE4D1981AC746E89ABBCBCBAE6F024F\",\"upc\":\"0005436107673\",\"wupc\":\"0005436107673\",\"USItemId\":24074298,\"USSellerId\":0},\"notes\":[]}]},{\"purchaseOrderNo\":\"1569950018149\",\"shipNode\":\"2377\",\"shipNodeType\":\"DC\",\"scac\":\"\",\"tcNumber\":\"02237020963141852820177\",\"shipToAddress\":{\"address\":{\"addressLineOne\":\"600 showers drive\",\"addressLineTwo\":\"\",\"addressLineThree\":\"\",\"addressLineFour\":\"\",\"addressLineFive\":\"\",\"addressLineSix\":\"\",\"addressType\":\"OFFICE\",\"city\":\"MountainView\",\"countryCode\":\"USA\",\"postalCode\":\"94040\",\"stateOrProvinceCode\":\"CA\",\"id\":null,\"isApoFpo\":false,\"isPoBox\":false},\"storeFrontId\":{\"storeFrontId\":null,\"USStoreId\":5502},\"name\":{\"firstName\":\"\",\"middleName\":\"\",\"lastName\":\"\",\"generalSuffix\":\"\",\"titleOfRespect\":\"\"},\"phone\":{\"completeNumber\":\"\"},\"smsMobileNo\":{\"completeNumber\":\"\"},\"email\":{\"emailAddress\":\"\"}},\"poDate\":[],\"purchaseOrderLines\":[{\"poLineId\":\"1\",\"primeLineNo\":1,\"poLineStatusInfos\":[{\"poLineStatus\":\"1100.200\",\"poLineStatusCode\":\"1100.200\",\"poLineStatusDescription\":\"PO Created\",\"poLineStatusChangeDate\":\"2014-12-04T10:19:05Z\",\"poLineStatusQuantity\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00}}],\"orderedQty\":{\"unitOfMeasure\":\"EA\",\"measurementValue\":2.00},\"requestOfferId\":{\"offerId\":\"539A698868664B2DB87ECB061D328722\",\"upc\":\"0005436107672\",\"wupc\":\"0005436107672\",\"USItemId\":10154038,\"USSellerId\":0},\"notes\":[]}]}],\"orderPreferences\":{\"isSendSMSNotification\":true}}}";
public static void main(String[] args) {
JSONObject jsonObject = (JSONObject)JSONValue.parse(JSON_DATA);
System.out.println("JSON: "+jsonObject.toJSONString());
}
}
答案 0 :(得分:0)
您拥有2.00
等值。
这些值读作double
。这种双精度的字符串表示是2.0
(注意缺少0)。
每次出现这样的双倍值时,该字符可减少1个字符。
你有43个这样的价值观。
你有它。