JD.com (JD  ) shares were up 13% following the company's better-than-expected Q2 earnings report despite a tough operating environment in China. The company topped analysts' estimates on the top and bottom line and also re-confirmed its guidance for the full year.

Overall, JD.com shares are down 7% YTD. And since early March, shares are up more than 50%. This is puzzling as there has been a steady stream of negative news and developments for Chinese stocks including the continuing and ongoing lockdowns, ramping up of political tensions due to the Taiwan issue, government crackdowns on tech companies, and constant chatter about de-listings given the U.S. Securities and Exchange Commission's (SEC) desire to increase scrutiny of Chinese companies listed in the U.S.

Inside the Numbers

In Q2, JD.com reported $0.61 per share which beat analysts' expectations of a profit of $0.41 per share. Revenue increased by 5.4% compared to last year and topped expectations at $40 billion vs $38.5 billion. Notably, this is the company's slowest quarter of revenue growth since its founding.

JD.com also saw a 9% increase in annual active customer accounts, reaching 580 million. Based on its quarter, JD.com has a forward price-to-earnings ratio of 31 which is pretty expensive relative to its peers, U.S. companies, and the magnitude of risks that are assumed by investors.

One silver lining is better than expected operating margins. It's a natural consequence of growth in the company's services business vs e-commerce which comes which puts upward pressure on gross margins.

Along with Ali Baba (BABA  ), JD.com is the biggest e-commerce company in China. It also is a provider of supply chain-based technology, services, and management services. And, the company has expanded into other niches like cloud computing, healthcare, and delivery.

So, the company has experienced some adverse, negative effects, but it's done a better job than Ali Baba of being proactive and staying on the right side of authorities. This is evident with the company's spin-off and listings of various units like JD Health, JD Logistics, and JD Digits.