APISonar


com.linkedin.restli.common.ContentType.JSON

> com > linkedin > restli > common > ContentType > JSON
com APIs linkedin APIs restli APIs common APIs ContentType APIs JSON APIs

Example 1
public void testNullContentType() throws MimeTypeParseException
  {
    ContentType contentType = ContentType.getContentType(null).get();
    Assert.assertEquals(ContentType.JSON, contentType);  // default to JSON for null content-type
  }
Example 2
public static ByteString dataMapToByteString(String contentTypeHeaderValue, DataMap dataMap) throws MimeTypeParseException, IOException
  {
    // TODO: We should throw an exception instead of using JSON for an unknown content type. This behavior was introduced
    // in commit d149605e4181349b64180bdfe0b4d24a294dc6f6 when this logic is refactored from DataMapUtils.readMapWithExceptions.
    ContentType contentType  = ContentType.getContentType(contentTypeHeaderValue).orElse(ContentType.JSON);

    return ByteString.unsafeWrap(contentType.getCodec().mapToBytes(dataMap));
  }
Example 3
public static DataMap bytesToDataMap(String contentTypeHeaderValue, ByteString bytes) throws MimeTypeParseException, IOException
  {
    ContentType contentType = ContentType.getContentType(contentTypeHeaderValue).orElse(ContentType.JSON);

    return contentType.getCodec().readMap(bytes.asInputStream());
  }
Example 4
public void testGetContentTypeDefault(MultiplexerRunMode multiplexerRunMode) throws Exception
  {
    createMultiplexer(null, multiplexerRunMode);
    RestRequest request = muxRequestBuilder().build();
    ContentType contentType = ContentType.getContentType(request.getHeader(RestConstants.HEADER_CONTENT_TYPE)).get();
    assertEquals(contentType, ContentType.JSON);
  }