AWS S3 putObject符号特殊字符(AWS S3 putObject symbols special chracters)
使用aws-sdk进行Javascript我遇到了一个奇怪的问题,在将文本放入对象后没有翻译特殊的字符
这是我的代码:
var AWS = require('aws-sdk'); AWS.config.update({ region: "us-east-1", endpoint: "s3.amazonaws.com" }); var s3 = new AWS.S3(); var params = { Bucket: 'test-example', Key: 'test.html', Body: 'Copyright © 2017', ACL:'public-read', ContentType: 'text/html' } s3.putObject(params, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response });
其中呈现的HTML页面显示:“ Copyright©2017 ”
如何删除添加字符Â
Using the aws-sdk for Javascript I'm running into a odd issue where special charaters are not being translated after putting the text into an object
Here is my code:
var AWS = require('aws-sdk'); AWS.config.update({ region: "us-east-1", endpoint: "s3.amazonaws.com" }); var s3 = new AWS.S3(); var params = { Bucket: 'test-example', Key: 'test.html', Body: 'Copyright © 2017', ACL:'public-read', ContentType: 'text/html' } s3.putObject(params, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response });
Which renders to an HTML page that displays: "Copyright © 2017"
How do I remove the addition character Â
原文:https://stackoverflow.com/questions/44380892
最满意答案
这里的问题是与“replies”属性关联的类型是动态的:它是字符串或JSON对象。 如果您使用的是.NET 4.0,则应使用dynamic关键字来反映数据的动态特性。 如果您使用的是其他版本的.NET,则可以反序列化为Newtonsoft.Json.Linq.JObject。 在这里看一个例子。 祝你好运。
The issue here is that the type associated with the "replies" property is dynamic: it is either a string or a JSON object. If you are using .NET 4.0 you should use the dynamic keyword to reflect the dynamic nature of the data. If you are using another version of .NET you can deserialize into a Newtonsoft.Json.Linq.JObject. Look here for an example. Best of luck.
相关问答
更多-
使用JSON.Net进行反序列化为所有字段返回null(VB)(Deserialization using JSON.Net return null for all fields (VB))[2024-01-05]
看看JSON的开头: {"customer":{"created_at"... 创建了一个外部容器来容纳您的代码未考虑的“客户”。 如果您不想为它创建一个do-nothing类,请先解析结果: Dim jstr = ...from whereever Dim jobj = JObject.Parse(jstr) Dim cust = JsonConvert.DeserializeObject(Of Customer)(jobj("customer").ToString) 要使用课程: Public C ... -
看起来这是一个可以通过替换轻松修复的错误 dr[columnName] = reader.Value 同 dr[columnName] = reader.Value ?? System.DBNull.Value 在Newtonsoft.Json.Converters.DataTableConverter中 。 我在跟踪器中输入了一个问题 。 It looks like this is a bug which is easily fixed by replacing dr[columnName] = re ...
-
所以我在这篇文章中找到了答案。 使用Newtonsoft JSON.NET反序列化Dynamic Json字符串 在我的模型中创建一个System.Dynamic.ExpandoObject类型的匿名对象允许反序列化器正常工作。 就是这样! So I found the answer in this post. Deserialize Dynamic Json string using Newtonsoft JSON.NET Making the anonymous Object in my model a ...
-
经过大量的挖掘,我解决了我的问题。 如果我反序列化包含字符串属性的复杂对象,那么结果中提出的所有解决方案才有效。 在这种情况下,是的,只需修改合同解析器就可以了[1]。 但是,我需要的是在反序列化时将任何字符串转换为null的方法,并且对于我的对象只是一个字符串的情况,以这种方式修改契约将失败,即, public void MyMethod(string jsonSomeInfo) { // At this point, jsonSomeInfo is "\"\"", // an emmpty st ...
-
假设您无法更改json,则需要创建一个具有Fruits属性的新FruitsWrapper类 public class FruitsWrapper { public Fruits Fruits { get; set; } } 并将json反序列化为FruitsWrapper而不是Fruits的实例 FruitsWrapper result = JsonConvert.DeserializeObject
(testJson); 工作演示: https : //dotnet ... -
要从JSON生成C#类,请尝试使用: http : //json2csharp.com/ 从它生成的有效 JSON: public class Step { public string name { get; set; } public List
Parameters { get; set; } } public class SubTest { public string name { get; set; } public int index { get; ... -
是的,类中的属性名称需要与JSON匹配(否则您需要在每个属性上使用[JsonProperty]属性来指示它们不同的JSON名称)。 将getHostsResponse类中hostlist属性的名称更改为result ,它应该开始工作。 您还将getHostsRecord的internal属性拼错为internala 。 修订课程如下: public class getHostsResponse { public string jsonrpc { get; set; } public List ...
-
尝试在模型中使用DataContract注释+使用DataContractJsonSerializer ,它应该可以正常工作: [DataContract] public class Conference { [DataMember] public string id { get; set; } [DataMember] public string datetime { get; set; } [DataMember] public string update ...
-
您可以使用jObject手动解析JSON: public class RecordFile { public string Page { get; set; } public string Context { get; set; } public Records Records { get; set; } } public class Records { public int RCount { get; set; } public IDictionary这里的问题是与“replies”属性关联的类型是动态的:它是字符串或JSON对象。 如果您使用的是.NET 4.0,则应使用dynamic关键字来反映数据的动态特性。 如果您使用的是其他版本的.NET,则可以反序列化为Newtonsoft.Json.Linq.JObject。 在这里看一个例子。 祝你好运。 The issue here is that the type associated with the "replies" property is dynamic: it is either a str ...
相关文章
更多- Amazon Web Services(AWS)概述
- 高负载低延迟:动态算法+Hadoop+AWS+NoSQL解析
- 《C++程序设计语言 特别版 十周年纪念版》(The C++ Programming Language Special Edition)扫描版[PDF]
- Just Forget To Ask The Handbag's Name
- Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years
- She’s Not Carrying A Handbag
- Storm,yahoo!S4比较
- Scott Hanselman's 推荐的的实用工具集合(2011版)
- Scott Hanselman's 推荐的的实用工具集合(2011版)
- Yahoo! s4和Twitter storm的粗略比较
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)