I have a JObject (I'm using Json.Net) that I constructed with LINQ to JSON (also provided by the same library). When I call the ToString() method on the JObject, it outputs the results as formatted JSON.

如何将此项的格式设置为"无"?

推荐答案

调用JObject的ToString(Formatting.None)方法.

或者,如果将对象传递给JsonConvert.SerializeObject方法它将返回不带格式的JSON.

文件:Write JSON text with JToken.ToString

Json相关问答推荐

当有嵌套数组而没有嵌套数组时,展平JSON

SWIFT中的网络经理

使用WSO2 JsonTransform Mediator对空值执行JsonExceptionUndeletedOperationException

在AWS步骤函数中将字符串解析为JSON&S映射状态

组合不同属性的Jolt Spec

使用JQ合并JSON列表中的对象

在linux控制台中解析json字符串的最简单方法是什么?

当并非所有子对象都有 Select 器字段时 Select

Jolt Spec 跳过数组中的第一个元素

当列为空时从 SQL 获取 JSON

使用 Power BI 中的 Deneb 视觉效果绘制面积图中的 X 轴日期

如何在 powerapps 中将详细信息表单转换为 json?

如何将从嵌套 Select 返回的空值转换为空数组?

PowerShell - 如何迭代 PSCustomObject 嵌套对象?

获取json中某个键的索引

将 JSON 数据导入 Google 表格

android - 在 adb logcat 输出中格式化 json 字符串

Jackson JSON序列化,通过级别定义避免递归

从 Json 对象 Android 中获取字符串值

为什么 RestTemplate 不将响应表示绑定到 PagedResources?