json

Laravel Eloquent object, longtext being truncated

做~自己de王妃 提交于 2021-02-19 07:12:58
问题 I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value. I tested in tinker. Simplified test code: $item = Item::find(1); echo $item->long_text_field; var_dump(json_decode($item->long_text_field)); echo strlen($item->long_text_field); On my local vagrant instance this shows the correct values. ...long json array in text, same

Laravel Eloquent object, longtext being truncated

主宰稳场 提交于 2021-02-19 07:12:39
问题 I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value. I tested in tinker. Simplified test code: $item = Item::find(1); echo $item->long_text_field; var_dump(json_decode($item->long_text_field)); echo strlen($item->long_text_field); On my local vagrant instance this shows the correct values. ...long json array in text, same

Scrapy returning scraped values into an array

一世执手 提交于 2021-02-19 07:10:12
问题 Scrapy seems to be pulling the data out correctly, but is formatting the output in my JSON object as if it were an array: [{"price": ["$34"], "link": ["/product/product..."], "name": ["productname"]}, {"price": ["$37"], "link": ["/product/product"]... My spider class looks like this: def parse(self, response): sel = Selector(response) items = sel.select('//div/ul[@class="product"]') skateboards = [] for item in items: skateboard = SkateboardItem() skateboard['name'] = item.xpath('li[@class=

Scrapy returning scraped values into an array

北战南征 提交于 2021-02-19 07:06:27
问题 Scrapy seems to be pulling the data out correctly, but is formatting the output in my JSON object as if it were an array: [{"price": ["$34"], "link": ["/product/product..."], "name": ["productname"]}, {"price": ["$37"], "link": ["/product/product"]... My spider class looks like this: def parse(self, response): sel = Selector(response) items = sel.select('//div/ul[@class="product"]') skateboards = [] for item in items: skateboard = SkateboardItem() skateboard['name'] = item.xpath('li[@class=

How can JAXB XmlAdapter be used to marshall lists?

落花浮王杯 提交于 2021-02-19 06:48:05
问题 Instances of this class are part of a large object graph and are not at the root of the object graph: public class Day { public Day(LocalDate date, List<LocalTime> times) { this.date = date; this.times = times; } public Day() { this(null, null); } public LocalDate getDate() { return date; } public List<LocalTime> getTimes() { return times; } private final LocalDate date; private final List<LocalTime> times; } The object graph is converted to JSON using Jersey and JAXB. I have XmlAdapter s

Receiving Websocket data in Swift

孤者浪人 提交于 2021-02-19 06:46:27
问题 I'm carrying this on from this question, since the focus has changed. I am trying to send string data from a vapor server over a websocket. The client side is where the main question is. This code successfully receives the string, which is expected to be JSON (but not absolutely guaranteed -- out of scope). switch message { case .data(let data): print("data: \(data)") case .string(let str): // let data = str.message(using: .utf8) let jsonData = Data(str.utf8) print("string: \(jsonData)") do {

Using computed value for sub key with React setState

时光怂恿深爱的人放手 提交于 2021-02-19 06:38:04
问题 I would like to be able to use computed values for sub keys when updating state in React. I understand how to use computed values in straightforward settings like this: this.setState({ [name]: value }); But I am having trouble getting key-value computation to work for a situation like this: constructor(props) { super(props); this.state = { foo: { a: 1, b: 2 } }; } const keyToChange = 'a'; const value = 3; this.setState({ foo[keyToChange]: value }); How can I make something that works like

JSONArray[0] is not a JSONObject exception

折月煮酒 提交于 2021-02-19 06:23:18
问题 I am trying to extract the ids from each company_id from the following Json String String test = ["{\"company_id\":4100,\"data\":{\"drm_user_id\":572901936637129135,\"direct_status_id\":0,\"direct_optin_date\":0,\"direct_first_optin_date\":0,\"direct_last_optin_date\":0,\"direct_optout_date\":0,\"direct_last_form_date\":0,\"direct_last_form_id\":0,\"direct_last_promo_id\":0,\"anon_status_id\":600,\"anon_optin_date\":1446132360498,\"anon_first_optin_date\":1446132360498,\"anon_last_optin_date\

ServiceStack OnDeserialized Equivalent

对着背影说爱祢 提交于 2021-02-19 06:16:48
问题 I am deserialize a websocket message in real time. In the message (string of json) I receive there is a unix timestamp (long). As soon as each object is deserialized I need it to call a method ASAP so that I can capture the delay between the time the message was sent and received. With Json.NET that was simple I just added this method to my DataContract class: [OnDeserialized] private void OnDeserialized(StreamingContext context) { Timestamp = DateTimeOffset.FromUnixTimeMilliseconds

Powershell Invoke-WebRequest and character encoding

半世苍凉 提交于 2021-02-19 06:10:18
问题 I am trying to get information from the Spotify database through their Web API. However, I'm facing issues with accented vowels (ä,ö,ü etc.) Lets take Tiësto as an example. Spotify's API Browser can display the information correctly: https://developer.spotify.com/web-api/console/get-artist/?id=2o5jDhtHVPhrJdv3cEQ99Z If I make a API call with Invoke-Webrequest I get Ti??sto as name: function Get-Artist { param($ArtistID = '2o5jDhtHVPhrJdv3cEQ99Z', $AccessToken = 'MyAccessToken') $URI = "https: