I have i small question about json serializing in dart. I am using "exportable" lib.
https://pub.dartlang.org/packages/exportable
Here a small code:
Condition t = new Condition();
Configurator configurator1 = new Exportable(Configurator);
configurator1.alias = conf_b_1;
configurator1.value = conf1;
Configurator configurator2 = new Exportable(Configurator);
configurator2.alias = conf_b_2;
configurator2.value = conf2;
t.configurators.add(configurator1);
ntp.condition = t;
print("________________toString_______________");
print(""+t.toString());
print("_______________________________________");
print("________________toJson_______________");
print(""+t.toJson());
print("_______________________________________");
and the result is:
________________toString_______________
{"ref":"4","logicalRefId":"41","value":"1","alias":false,"configurators":["{\"alias\":\"1\",\"value\":\"10\"}"]}
________________toJson_______________
{"ref":"4","logicalRefId":"41","value":"1","alias":false,"configurators":["{\"alias\":\"1\",\"value\":\"10\"}"]}
The configurator part is totally broken. Where am i doing it wrong ?
Thx in advance for reading me,
Nerio.
Related
Does anyone know where "com.amazonaws.services.dynamodbv2.document.Item", item.fromJSON(), and Item.toJSON() are in the aws-sdk-java-v2?
I'm looking to migrate the following code:
-- From v1 --
AmazonDynamoDB dynamoDB = AmazonDynamoDBClientBuilder
...
DynamoDB dynamo = new DynamoDB(dynamoDB);
dbtable = dynamo.getTable(table);
dbtable.putItem(Item.fromJSON(jsonString));
Item item = dbtable.getItem(spec);
String jsonString = item.toJSON();
-- To v2 --
DynamoDbClient ddbClient = DynamoDbClient
.builder()
...
.build();
??? dbtable.putItem(Item.fromJSON(jsonString))
??? jsonString = dbtable.getItem(spec).toJSON()
Not sure I fully understand you question, but if you are just looking for the code, it is here:
https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/Item.java
starting at line 1236.
Found the answer. The DynamoDB Document API HAS NOT been implemented in the aws-sdk-java-v2 libraries.
Github feature request can be found here: https://github.com/aws/aws-sdk-java-v2/issues/36
Im trying to insert new data into the DB when a user scans a barcode into a field. When I hit save on the screen it says fail to convert circular structure to json.
var report = myapp.activeDataWorkspace.BlanccoData.BMCReports.addNew();
report.c_Date = Date.now();
report.IsScannedReport = true;
if (contentItem.screen.ScanSSN == true) {
report.SSN = contentItem.value;
}
var system = myapp.activeDataWorkspace.BlanccoData.BMCSystemInfo.addNew();
// system.Report = report;
system.Barcode = contentItem.screen.Barcode;
I think the commented line is throwing the exception but I need to reference it.
thanks
Have you considered that you may have a circular relationship in your database? That is reflected in your DataSource?
i am developing an iOS app and this app fetches data using JSON from mysql database. i have configured the json properly so far. right hand $outputs are ok and json validator validated the json formatting is completely ok. but my left hand tags are not appearing some how. here i m providing the code what i did. For this app publishing is on hold for long time.
//fetch data from current month table
$q = mysql_query("SELECT * FROM $monthyear where news_date = '$date'");
if (!$q) {
die('Invalid query executed: ' . mysql_error());
}
while($e=mysql_fetch_row($q)){
$output[]=$e;
$responce[$e]['news_id'] = $output['news_id'];
$responce[$e]['news_title'] = $output['news_title'];
$responce[$e]['news_reporter'] = $output['news_reporter'];
$responce[$e]['news_details'] = $output['news_details'];
$responce[$e]['photo'] = $output['photo'];
$responce[$e]['path'] = 'admin/'.str_replace('\\','',$output['path']);
$responce[$e]['menu_id'] = $output['menu_id'];
$responce[$e]['menu_type'] = $output['menu_type'];
$responce[$e]['news_publish_status'] = $output['news_publish_status'];
$responce[$e]['news_order'] = $output['news_order'];
$responce[$e]['news_date'] = $output['news_date'];
$responce[$e]['news_time'] = $output['news_time'];
$responce[$e]['added_by'] = $output['added_by'];
$responce[$e]['directory'] = $output['directory'];
$responce[$e]['read_number'] = $output['read_number'];
$responce[$e]['comment_number'] = $output['comment_number'];
$responce[$e]['news_comment_table_name'] = $output['news_comment_table_name'];
}
echo(json_encode($output));
I am not getting any way to show left hand tags though it exists in the script. can any one help me on this by guiding or giving an example from existing source code after modifications. TIA
Ishtiaque
You are using $e which is an array as an array key in $response[$e], and this is not allowed in PHP:
Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.
I think you want to use the ID as a key.
I'm working on a T4 file that generates .cs classes based on an entity model, and one of the things I'm trying to get to is the mapping info in the model. Specifically, for each field in the model I'm trying retrieve the database field name it is mapped to.
I've found that the mapping info is apparently stored in StorageMappingItemCollection, but am having an impossible time figuring out how to query it and retrieve the data I need. Has anyone worked with this class and can maybe provide guidance?
The code I have so far goes something like this (I've pasted everything up to the problematic line):
<#
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
#>
<## template language="C#" debug="true" hostspecific="true"#>
<## include file="EF.Utility.CS.ttinclude"#>
<## output extension=".cs"#><#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, 1);
MetadataTools ef = new MetadataTools(this);
string inputFile = #"MyModel.edmx";
EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile);
StoreItemCollection storeItemCollection = null;
loader.TryCreateStoreItemCollection(inputFile, out storeItemCollection);
StorageMappingItemCollection storageMappingItemCollection = null;
loader.TryCreateStorageMappingItemCollection(
inputFile, ItemCollection, storeItemCollection, out storageMappingItemCollection);
var item = storageMappingItemCollection.First();
storageMappingItemCollection has methods like GetItem() and such, but I can't for the life of me get it to return data on fields that I know exist in the model.
Thx in advance!
Parsing the MSL isn't really that hard with Linq to XML
string mslManifestResourceName = GetMslName(ConfigurationManager.ConnectionStrings["Your Connection String"].ConnectionString);
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(mslManifestResourceName);
XmlReader xreader = new XmlTextReader(stream);
XDocument doc = XDocument.Load(xreader);
XNamespace xmlns = "http://schemas.microsoft.com/ado/2009/11/mapping/cs";
var items = from entitySetMap in doc.Descendants(xmlns + "EntitySetMapping")
let entityTypeMap = entitySetMap.Element(xmlns + "EntityTypeMapping")
let mappingFragment = entityTypeMap.Element(xmlns + "MappingFragment")
select new
{
EntitySet = entitySetMap.Attribute("Name").Value,
TypeName = entityTypeMap.Attribute("TypeName").Value,
TableName = mappingFragment.Attribute("StoreEntitySet").Value
};
It may be easier to parse the EDMX file as XML rather than using the StorageMappingItemCollection.
I am trying to update a POCO using lin2sql. I can also use entity framework. For updating objects I follow the next routine.
//GridView Control gives me some updated POCOS As an Example: Person updated;
function UpdatePerson(Person myUpdatedPersonfromUI)
{
using (Entity con = new Entity() ) {
var recordFromdB = from obj in con.Person where obj.PK = myUpdatedPersonfromUI.PK
select obj;
Person personOnDB = recordFromdB.Single();
// now for each column I update personOnDB
personOnDB.Property1 = myUpdatedPersonfromUI.Property1 ;
personOnDB.Property2 = myUpdatedPersonfromUI.Property2 ;
personOnDB.Property3 = myUpdatedPersonfromUI.Property3 ;
personOnDB.Property4 = myUpdatedPersonfromUI.Property4 ;
// continue updating fields ...
..
.
personOnDB.Property124 = myUpdatedPersonfromUI.Property124 ;
con.SaveChanges();
}
}
Do I have to update each property manually . Please help .
You can use an object mapping tool like AutoMapper which pretty much will do the work for you - in this simple case (property names match between source and target) it would be a one-liner to map these.
Given that you are using you same object type in the UI, why not just plug it into the DAL and call update directly?
This link gives details on how to do it.