converter

How to convert string to object in Angularjs [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-10 01:42:14
问题 This question already has answers here : Parse JSON in JavaScript? [duplicate] (16 answers) Closed 3 years ago . I have a string like : $scope.text = '"{\"firstName\":\"John\",\"age\":454 }"'; and I want to convert to js object: $scope.tmp = {"firstName":"John","age":454 }; Note: JSON.parse() doesn't work!! It's my sample in codepen 回答1: You can do it with angular.fromJson() in your sample, it would have been $scope.tmp = angular.fromJson($scope.text); The difference between JSON.Parse() and

convert string to hex in python

烈酒焚心 提交于 2019-12-10 01:10:12
问题 I have a script that calls a function that takes a hexadecimal number for an argument. The argument needs to the 0x prefix. The data source is a database table and is stored as a string, so it is returned '0x77'. I am looking for a way to take the string from the database and use it as an argument in hex form with the 0x prefix. This works: addr = 0x77 value = class.function(addr) The database entry has to be a string, as most of the other records do not have hexadecimal values in this column

Improve SQL Server query to convert arbitrary table to JSON

时光毁灭记忆、已成空白 提交于 2019-12-09 15:58:57
问题 After a lot of searching and piecing together the very excellent techniques for converting result sets using the FOR XML and .nodes() commands that are around the web, I was able to create this single query (not a stored procedure) which does a reasonably good job of converting any arbitrary SQL query to a JSON array. The query will encode each data row as a single JSON object with a leading comma. The data rows are wrapped by brackets and the whole result set is then expected to be exported

Creating custom tag for Converter with attributes

自闭症网瘾萝莉.ら 提交于 2019-12-09 01:28:23
问题 I have found a Converter online and changed it to my needs as far as I could. The problem is though that I need to add a flag (i.e. a string) that must be checked and than the converter must apply a certain pattern to a string. Custom Converter: @FacesConverter("convtest.UrlConverter") public class UrlConverter implements Converter { @Override public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { StringBuilder url = new StringBuilder(); if(value!=null){

IValueConverter with MarkupExtension

孤街浪徒 提交于 2019-12-08 22:00:36
问题 Recently I read about an IValueConverter which also inherits from MarkupExtension . It was something like: internal class BoolToVisibilityConverter : MarkupExtension, IValueConverter { private static BoolToVisibilityConverter converter; public BoolToVisibilityConverter() { } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool) { if ((bool)value) { return Visibility.Visible; } } return Visibility.Collapsed; } public object ConvertBack

How to convert raw BGRA image to JPG using GStreamer 1.0?

只谈情不闲聊 提交于 2019-12-08 18:04:24
I'm trying to display a raw image (1.8MB) with gst-launch-1.0 . I understand that the data needs to be encoded to JPG before this can be achieve. If image was already stored as a jpg file the story would be quite simple: gst-launch-1.0.exe -v filesrc location=output.jpg ! decodebin ! imagefreeze ! autovideosink However, I need to assemble the pipeline to display a raw BGRA 800x600 image (looks the same as the above) that was dumped to the disk by a 3D application. This is what I've done so far, but the problem is that it creates a completely black image on the disk: gst-launch-1.0.exe -v

WPF converters: where does the culture come from

二次信任 提交于 2019-12-08 17:12:03
问题 I've created a WPF converter class: public class DoubleConverter : IValueConverter { public object Convert(object value, Type TargetType, object parameter, CultureInfo culture) { //blah blah } } I wonder who sets the culture parameter that is passed. I would expect it to be the same as the current windows settings, but it appears to be different. Anyone? 回答1: This page describes a bug (feature?) of WPF where culture will always be en-US unless you take action to specify otherwise and how to

Is there a faster way of converting a number to a name?

不想你离开。 提交于 2019-12-08 16:27:17
问题 The following code defines a sequence of names that are mapped to numbers. It is designed to take a number and retrieve a specific name. The class operates by ensuring the name exists in its cache, and then returns the name by indexing into its cache. The question in this: how can the name be calculated based on the number without storing a cache? The name can be thought of as a base 63 number, except for the first digit which is always in base 53. class NumberToName: def __generate_name():

WPF ColorAnimation for a Brush property

别等时光非礼了梦想. 提交于 2019-12-08 15:58:42
问题 I wonder if someone can help me - I've got a label which I need to be able to cross-fade between any 2 colors when a method is called in the code behind. My best attempt so far: Private OldColor as Color = Colors.White Sub SetPulseColor(ByVal NewColor As Color) Dim F As New Animation.ColorAnimation(OldColor, NewColor, New Duration(TimeSpan.Parse("00:00:01"))) OldColor = NewColor F.AutoReverse = False PulseLogo.BeginAnimation(Label.ForegroundProperty, F) End Sub The problem I have is that

Fortran type conversions

我们两清 提交于 2019-12-08 11:26:23
问题 I have the following command to set my array Use, Intrinsic :: iso_fortran_env Integer (Int8), Allocatable :: iu(:) Allocate (iu(4)) iu = [4,3,2,1] How can I stop the compiler giving me Allocate (iu(4)); iu = [4,3,2,1] 1 Warning: Possible change of value in conversion from INTEGER(4) to INTEGER(1) at (1) [-Wconversion] 回答1: High Performance Mark's answer about solves your problem. However, assuming int8 isn't the default kind (which the error messages supports) each element in the array