mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3b31e69e28
Summary: Changelog: [General] [Fixed] - License header cleanup Reviewed By: yungsters Differential Revision: D17952694 fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package com.facebook.react.util;
|
|
|
|
import android.util.JsonWriter;
|
|
import com.facebook.react.bridge.JsonWriterHelper;
|
|
import com.facebook.react.bridge.ReadableMap;
|
|
import com.facebook.react.bridge.ReadableType;
|
|
import java.io.IOException;
|
|
import java.io.StringWriter;
|
|
import java.io.Writer;
|
|
import javax.annotation.Nullable;
|
|
|
|
public class ExceptionDataHelper {
|
|
static final String EXTRA_DATA_FIELD = "extraData";
|
|
|
|
public static String getExtraDataAsJson(@Nullable ReadableMap metadata) {
|
|
if (metadata == null || metadata.getType(EXTRA_DATA_FIELD) == ReadableType.Null) {
|
|
return null;
|
|
}
|
|
try {
|
|
Writer extraDataWriter = new StringWriter();
|
|
JsonWriter json = new JsonWriter(extraDataWriter);
|
|
JsonWriterHelper.value(json, metadata.getDynamic(EXTRA_DATA_FIELD));
|
|
json.close();
|
|
extraDataWriter.close();
|
|
return extraDataWriter.toString();
|
|
} catch (IOException ex) {
|
|
}
|
|
return null;
|
|
}
|
|
}
|