Problem Deserializing MarketData object from Json


I’m attempting to expose MarketData objects via a web service. As far as I can see, JSON serialization works fine. I’m having difficulties with deserializing the JSON back into a MarketData (specifically BuiltMarketData) object. Note: This works correctly for XML serialization/deserialization. The following code demonstrates the issue with JSON deserialization:

public MarketData getCalibratedMarketData(LocalDate valDate, Instance instance) {
		CalculationRules rules = CalculationRules.of(StandardComponents.calculationFunctions(),

		MarketDataRequirements reqs = MarketDataRequirements.of(rules,
							getTrades(valDate, instance).toJavaList(),
							ImmutableList.of(Column.of(Measures.PRESENT_VALUE)), refData);

		MarketDataConfig marketDataConfig = MarketDataConfig.builder()
							.add(groupName, getCurveGroupDefinition(valDate)).build();

		return StandardComponents.marketDataFactory().create(reqs, marketDataConfig,
							getMarketData(valDate, instance), refData);

Tests serialization and deserialization:

		BuiltMarketData mktData = (BuiltMarketData) curveService.getCalibratedMarketData(valDate, instance);
		String json = JodaBeanSer.COMPACT.jsonWriter().write(mktData);
		mktData = JodaBeanSer.COMPACT.jsonReader().read(json, BuiltMarketData.class);

Attempting this throws an exception:

    "timestamp": "2018-02-08T23:06:52.494+0000",
    "status": 500,
    "error": "Internal Server Error",
    "exception": "java.lang.IllegalArgumentException",
    "message": "Error parsing bean: com.opengamma.strata.calc.marketdata.BuiltMarketData::underlying, Error parsing bean: com.opengamma.strata.calc.marketdata.BuiltScenarioMarketData::underlying, Error parsing bean:, Error parsing bean:, Error parsing bean:, null",
    "path": "/curves/calibrated-marketdata"


Unfortunately, your code sample is missing too many pieces to reproduce the error. This includes the curve group definition, the trades and the input market data. Even just the JSON form would be useful.



I didn’t want to post my code to GitHub etc. But I’ve attached it here. It has a dependency on our market data server but should be enough for you to reproduce. As mentioned in my post the XML serialization is working but JSON fails.



Sorry, need this is as well to compile:


Unfortunately, your attachments didn’t make it through our forum’s security settings. Perhaps you could post the serialized XML inline, as then I can deserialize that and use it for testing JSON.

thanks for your patience


I think the issue was this one which has now been released as Joda-Beans v2.1.


Thank you, upgrading to JB 2.1 solved my issue