What's the format of this data? - format

Here is the data:
a:6:
{
s:8:"post_num";i:10476;
s:8:"good_num";i:1;
s:12:"manager_info";a:2:{
s:7:"manager";a:2:{
s:10:"forum_list";a:0:{
}
s:5:"count";i:0;
}
s:6:"assist";a:2:{
s:10:"forum_list";a:2:{
i:0;s:4:"sdsd";
i:1;s:6:"xxxxxx";
}
s:5:"count";i:2;
}
}
s:10:"like_forum";a:5:{
i:12;a:2:{
s:10:"forum_list";a:1:{
i:0;s:4:"xxxx";
}
s:5:"count";i:1;
}
i:11;a:2:{
s:10:"forum_list";a:2:{
i:0;s:8:"xxxxxxxx";
i:1;s:8:"xxxxxxxx";
}
s:5:"count";i:8;
}
i:10;a:2:{
s:10:"forum_list";
a:1:{
i:0;s:6:"kindle";
}
s:5:"count";i:1;
}
i:9;a:2:{
s:10:"forum_list";a:1:{
i:0;s:3:"psv";
}
s:5:"count";i:1;
}
i:7;a:2:{
s:10:"forum_list";a:1:{
i:0;s:3:"eve";
}
s:5:"count";i:1;
}
}
s:9:"is_novice";i:0;
s:7:"op_time";i:1429690795;
}
After I format it like this , I found :
a is object
s is string
i is int
The number after the char above is length, a:6 means the object has 6 children.
So I want to convert it into java bean , I can write code to parse it, but I'm wondering whether it is a existing data format ? If so I can use more reliable third-part library's code.

It is serialized data of PHP objects/values, in the PHP serialization format.
For more detail, see http://www.phpinternalsbook.com/classes_objects/serialization.html

Related

Convert kj::Promise<kj::Exception> to kj::Promise<void>

I can return a kj::Exception where a kj::Promise is expected, like so:
kj::Promise<void> someFunc() {
return KJ_EXCEPTION(FAILED, "some description");
}
But what if I end up having a kj::Promise<kj::Exception> in a place where I don't have a waitScope? For instance:
kj::Promise<void> someFunc(kj::Promise<void> somePromise) {
return somePromise.then([]() {
return KJ_EXCEPTION(FAILED, "some description");
});
}
There my compiler complains that there is no valid conversion between kj::Promise<kj::Exception> and kj::Promise<void>.
Is there a way around that?
I'm a little surprised that I didn't prohibit Promise<Exception> in the first place; using such a construction likely leads to a lot of problems.
You can avoid it in your code by explicitly declaring the return type of the lambda to be Promise<void>, i.e.:
return somePromise.then([]() -> kj::Promise<void> {

I have two jsonata files but i have to take particular field from jsonata1 and merge that particular field in jsonata2

For example
Json1:
{
"Data":"123",
"Data1":"345"
}
Jsonata1:
{
"Data":$.Data,
"Data1":$.Data1
}
Json2:
{
"Prod":"675",
"Prod2":"564"
}
Jsonata2:
{
"Prod":$.Data
}
How can I use like this if u observed my jsonata2 I call the jsonata1 feild data
I can't find any suggestions
Please help me resolve the issue

Reusing GraphQL fragments

I am using Prismic, and I have two identical custom types, one is called Content and one is called Theme. Their data is identical so I would like to reuse my fragments, is it possible?
An example fragment looks like:
import { graphql } from 'gatsby'
export const CollectionFragment = graphql`
fragment CollectionFragment on PrismicContentBodyCollection {
...
}
`
So right now it is hardcoded to PrismicContentBodyCollection.
A GraphiQL example would look like:
query MyQuery {
allPrismicTheme {
nodes {
data {
body {
... on PrismicThemeBodyHero {
slice_type
}
}
}
}
}
allPrismicContent {
nodes {
data {
body {
... on PrismicContentBodyHero {
slice_type
}
}
}
}
}
}
I'm not 100% sure, but I don't think this is possible because it needs to be specified with the type that matches the type of document you're looking for to make sure that your query is valid and that the fields you are trying to receive actually exist on the object.
So in your case, if you're looking for the Collection Slice, the fragments would need to be
PrismicThemeBodyCollection and PrismicContentBodyCollection respectively.
I have made a few tests myself and I keep getting errors that say I'm missing the correct content type name

Is there any method to pass protobuf object to shared_ptr?

I want to copy protobuf msg "SmConfig" to an shared_ptr like below:
SignalMachine::SignalMachine(SmConfig* sm_config) {
sm_config_ = std::make_shared<SmConfig>();
sm_config_.CopyFrom(*sm_config);
}
class SignalMachine {
private:
std::shared_ptr<SmConfig> sm_config_;
}
Because I need to keep SmConfig(protobuf) in "class SignalMachine", I used the above method, is it reasonable? in fact, I did not find the corresponding description in the official document.
You can use copy constructor:
SignalMachine::SignalMachine(SmConfig* sm_config) {
if (sm_config != nullptr)
sm_config_ = std::make_shared<SmConfig>(*sm_config);
// else error handling
}

Is there a way to let Apollo Client globally insert empty strings during loading?

I'm using Apollo Client to receive the GraphQL data for my application. Over time, I see a pattern emerging where for every value I'm querying, I have to include a conditional statement to handle the moment where my data is still loading.
Assume a query looks like this:
query TestQuery($userId: Int!) {
getUser(id: $userId) {
name
}
}
Then, in every place where I want to display the user name, I have to write something like:
{ !this.props.data.loading && this.props.data.getUser.name }
or
{ this.props.data.getUser && this.props.data.getUser.name }
I don't want to display "Loading..." or a rotating spinner in any of these places. Is there a way to avoid this conditional statement by globally replacing all this.props.data.x.y.z values with null or an empty String during loading?
If so, how? Would this be considered an antipattern or bad practice?
If not, which of the above two forms is preferred?
Thanks.
How about this approach?
class GraphqlComponent extends React.Component {
renderError(){
// ...
}
renderLoading(){
// ...
}
renderLoaded(){
}
render(){
const { loading, error } = this.props;
if(error){
return renderError();
}
if(loading){
return renderLoading();
}
return renderLoaded();
}
}
class MyComponent extends GraphqlComponent{
renderLoaded(){
// your logic goes here
}
}

Resources