tests: extract JSON logic from test_deserialization